You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
330 lines
14 KiB
C#
330 lines
14 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Configuration;
|
|
using System.Data;
|
|
using System.Web;
|
|
using System.Web.Security;
|
|
using System.Web.UI;
|
|
using System.Web.UI.HtmlControls;
|
|
using System.Web.UI.WebControls;
|
|
using System.Web.UI.WebControls.WebParts;
|
|
using DSWeb.Models;
|
|
using DSWeb.EntityDA;
|
|
|
|
namespace DSWeb.Settlements
|
|
{
|
|
public partial class ReceiveAmountEdit : System.Web.UI.Page
|
|
{
|
|
private string strCompanyID;//公司GID
|
|
private string strShowName;//用户显示名
|
|
private string strDeptName;//部门名称
|
|
private string strUserID;//登录人GID
|
|
private string strHandle;
|
|
private string strReceiveAmountID;//实收GID
|
|
private string strOperateName;//操作名称
|
|
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (Session["USERID"] != null)
|
|
{
|
|
strUserID = Session["USERID"].ToString();
|
|
|
|
}
|
|
if (Session["SHOWNAME"] != null)
|
|
{
|
|
strShowName = Session["SHOWNAME"].ToString();
|
|
this.h_showname.Value = strShowName;
|
|
}
|
|
if (Session["COMPANYID"] != null)
|
|
{
|
|
strCompanyID = Session["COMPANYID"].ToString();
|
|
this.h_compid.Value = strCompanyID;
|
|
}
|
|
if (Session["DEPTNAME"] != null)
|
|
{
|
|
strDeptName = Session["DEPTNAME"].ToString();
|
|
}
|
|
|
|
if (Request.QueryString["handle"] != null)
|
|
{
|
|
strHandle = Request.QueryString["handle"].ToString().Trim().ToLower();
|
|
}
|
|
|
|
if (Request.QueryString["id"] != null)
|
|
{
|
|
strReceiveAmountID = Request.QueryString["id"].ToString();
|
|
}
|
|
|
|
if (Request.QueryString["op"] != null)
|
|
{
|
|
strOperateName = Request.QueryString["op"].ToString().Trim().ToLower();
|
|
}
|
|
|
|
if (strHandle != null)
|
|
{
|
|
if (strHandle == "add")
|
|
{
|
|
ReceiveAmountDA receiveAmountDA = new ReceiveAmountDA();
|
|
this.dvCreateUserVal.InnerHtml = strShowName;
|
|
this.txt_recvtime.Value = receiveAmountDA.GetServerDateTime().ToString("yyyy-MM-dd hh:mm:ss");
|
|
}
|
|
}
|
|
|
|
if (this.h_post.Value.Trim().Equals("1"))
|
|
{
|
|
SaveReceiveAmount();
|
|
}
|
|
else
|
|
{
|
|
if (strReceiveAmountID != null)
|
|
{
|
|
UserDA userDA = new UserDA();
|
|
ReceiveAmountEntity receiveAmountEntity = new ReceiveAmountEntity();
|
|
ReceiveAmountDA receiveAmountDA = new ReceiveAmountDA();
|
|
|
|
receiveAmountEntity = receiveAmountDA.GetRecvAmountByGID(strReceiveAmountID);
|
|
|
|
if (receiveAmountEntity != null)
|
|
{
|
|
if (receiveAmountEntity.GID != null)
|
|
{
|
|
this.dvRecvAmountNoVal.InnerHtml = receiveAmountEntity.NO;
|
|
this.txt_name.Value = receiveAmountEntity.Description;
|
|
this.txt_recvamount.Value = receiveAmountEntity.ReceiveAmount.ToString();
|
|
this.sel_currency.Value = receiveAmountEntity.Currency;
|
|
this.h_clientid.Value = receiveAmountEntity.ClientID;
|
|
this.sel_settletype.Value = receiveAmountEntity.SettleType.ToString();
|
|
this.txt_voucher.Value = receiveAmountEntity.VoucherNO;
|
|
this.h_bank.Value = receiveAmountEntity.Bank;
|
|
this.h_account.Value = receiveAmountEntity.Account;
|
|
//this.dvCreateTimeVal.InnerHtml = receiveAmountEntity.CreateTime.ToString();
|
|
this.txt_recvtime.Value = receiveAmountEntity.CreateTime.ToString();
|
|
this.txt_doamount.Value = receiveAmountEntity.DoAmount.ToString();
|
|
this.txt_remark.Value = receiveAmountEntity.Remark;
|
|
this.h_companyid.Value = receiveAmountEntity.CompanyID;
|
|
this.sel_verifycurrency.Value = receiveAmountEntity.Currency;
|
|
this.txt_undoamount.Value = (receiveAmountEntity.ReceiveAmount - receiveAmountEntity.DoAmount).ToString();
|
|
this.sel_verifycurrency.Value = receiveAmountEntity.Currency;
|
|
|
|
UserEntity userEntity = userDA.GetUserAllByID(receiveAmountEntity.CreateUser);
|
|
this.dvCreateUserVal.InnerHtml = userEntity.ShowName;
|
|
|
|
CRMClientDA crmClientDA = new CRMClientDA();
|
|
CRMClientEntity crmClientEntity = crmClientDA.GetCrmClientInfoByGID(receiveAmountEntity.ClientID);
|
|
|
|
this.h_customer.Value = crmClientEntity.ShortName;
|
|
this.h_clientid.Value = crmClientEntity.GID;
|
|
|
|
if (receiveAmountEntity.DoAmount > 0 || strOperateName == "verify")
|
|
{
|
|
this.txt_name.Disabled = true;
|
|
this.txt_recvamount.Disabled = true;
|
|
this.sel_currency.Disabled = true;
|
|
this.sel_settletype.Disabled = true;
|
|
this.txt_voucher.Disabled = true;
|
|
this.txt_remark.Disabled = true;
|
|
this.h_onlyread.Value = "1";
|
|
this.btn_save.Disabled = true;
|
|
this.txt_recvtime.Disabled = true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private void SaveReceiveAmount()
|
|
{
|
|
ReceiveAmountEntity receiveAmountEntity = new ReceiveAmountEntity();
|
|
ReceiveAmountDA receiveAmountDA = new ReceiveAmountDA();
|
|
|
|
if (h_recvamountid.Value.Trim() != "")
|
|
{
|
|
strReceiveAmountID = h_recvamountid.Value.Trim();
|
|
}
|
|
|
|
if (strReceiveAmountID != null)
|
|
{
|
|
receiveAmountEntity.GID = strReceiveAmountID;
|
|
receiveAmountEntity.Description = "";//this.txt_name.Value.Trim();
|
|
receiveAmountEntity.ReceiveAmount = this.txt_recvamount.Value.Trim().Equals("") ? 0 : decimal.Parse(this.txt_recvamount.Value.Trim());
|
|
receiveAmountEntity.ClientID = this.h_clientid.Value;
|
|
receiveAmountEntity.Currency = this.sel_currency.Value;
|
|
receiveAmountEntity.VoucherNO = this.txt_voucher.Value.Trim();
|
|
receiveAmountEntity.Bank = this.h_bank.Value.Trim();
|
|
receiveAmountEntity.Account = this.h_account.Value.Trim();
|
|
receiveAmountEntity.SettleType = int.Parse(this.sel_settletype.Value);
|
|
receiveAmountEntity.ModifiedUser = strUserID;
|
|
receiveAmountEntity.Remark = this.txt_remark.Value.Trim();
|
|
receiveAmountEntity.CompanyID = h_companyid.Value.Trim();
|
|
receiveAmountEntity.CreateTime = DateTime.Parse(Request.Form["txt_recvtime"].ToString().Trim());
|
|
|
|
int tempResult = receiveAmountDA.UpdateReceiveAmount(receiveAmountEntity);
|
|
|
|
if (tempResult == 1)
|
|
{
|
|
this.h_recvamountid.Value = receiveAmountEntity.GID;
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "notice", "<script>alert('保存成功!');</script>");
|
|
}
|
|
this.h_post.Value = "";
|
|
}
|
|
else
|
|
{
|
|
receiveAmountEntity.GID = Guid.NewGuid().ToString();
|
|
receiveAmountEntity.Description = this.txt_name.Value.Trim();
|
|
receiveAmountEntity.ReceiveAmount = this.txt_recvamount.Value.Trim().Equals("") ? 0 : decimal.Parse(this.txt_recvamount.Value.Trim());
|
|
receiveAmountEntity.ClientID = this.h_clientid.Value;
|
|
receiveAmountEntity.Currency = this.sel_currency.Value;
|
|
receiveAmountEntity.VoucherNO = this.txt_voucher.Value.Trim();
|
|
receiveAmountEntity.Bank = this.h_bank.Value.Trim();
|
|
receiveAmountEntity.Account = this.h_account.Value.Trim();
|
|
receiveAmountEntity.CompanyID = strCompanyID;
|
|
receiveAmountEntity.SettleType = int.Parse(this.sel_settletype.Value);
|
|
receiveAmountEntity.CreateUser = strUserID;
|
|
receiveAmountEntity.Remark = this.txt_remark.Value.Trim();
|
|
receiveAmountEntity.CreateTime = DateTime.Parse(Request.Form["txt_recvtime"].ToString().Trim());
|
|
|
|
receiveAmountEntity.NO = CreateSettleCode(GetChineseSpell(strShowName));
|
|
int tempResult = receiveAmountDA.InsertReceiveAmount(receiveAmountEntity);
|
|
|
|
if (tempResult == 1)
|
|
{
|
|
this.h_recvamountid.Value = receiveAmountEntity.GID;
|
|
this.dvRecvAmountNoVal.InnerHtml = receiveAmountEntity.NO;
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "notice","<script>alert('保存成功!');</script>");
|
|
}
|
|
this.h_post.Value = "";
|
|
}
|
|
}
|
|
|
|
private string GetChineseSpell(string strText)
|
|
{
|
|
int len = strText.Length;
|
|
string myStr = "";
|
|
for (int i = 0; i < len; i++)
|
|
{
|
|
myStr += getSpell(strText.Substring(i, 1));
|
|
}
|
|
return myStr;
|
|
}
|
|
//取首字母方法
|
|
static public string getSpell(string myChar)
|
|
{
|
|
byte[] arrCN = System.Text.Encoding.Default.GetBytes(myChar);
|
|
if (arrCN.Length > 1)
|
|
{
|
|
int area = (short)arrCN[0];
|
|
int pos = (short)arrCN[1];
|
|
int code = (area << 8) + pos;
|
|
int[] areacode = { 45217, 45253, 45761, 46318, 46826, 47010, 47297, 47614, 48119, 48119, 49062, 49324, 49896, 50371, 50614, 50622, 50906, 51387, 51446, 52218, 52698, 52698, 52698, 52980, 53689, 54481 };
|
|
for (int i = 0; i < 26; i++)
|
|
{
|
|
int max = 55290;
|
|
if (i != 25) max = areacode[i + 1];
|
|
if (areacode[i] <= code && code < max)
|
|
{
|
|
return System.Text.Encoding.Default.GetString(new byte[] { (byte)(65 + i) });
|
|
}
|
|
}
|
|
return "*";
|
|
}
|
|
else return myChar;
|
|
}
|
|
|
|
private string CreateSettleCode(string tempSpellName)
|
|
{
|
|
int CodeLength = 4;
|
|
string strSettleCode = "";
|
|
|
|
//获取分公司的票号头字符
|
|
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
|
|
string tempBANKSHEAD = T_ALL_DA.GetStrSQL("BANKSHEAD", "SELECT TOP 1 BANKSHEAD FROM company WHERE GID='" + strCompanyID.Trim() + "'");
|
|
string strFeeType = tempBANKSHEAD+tempSpellName;
|
|
ReceiveAmountDA receiveAmountDA = new ReceiveAmountDA();
|
|
DateTime nowDateTime = receiveAmountDA.GetServerDateTime();
|
|
|
|
string strYear = nowDateTime.Year.ToString();
|
|
string strMonth = nowDateTime.Month.ToString().Length < 2 ? "0" + nowDateTime.Month.ToString() : nowDateTime.Month.ToString();
|
|
//string strDay = nowDateTime.Day.ToString();
|
|
string strDateTime = strYear + strMonth;
|
|
string strCodePrefix = strFeeType + strDateTime;
|
|
|
|
//string strSql = "SELECT TOP 1 BILLNO FROM ch_fee_do WHERE BILLNO LIKE '" + strFeeType + strDateTime + "%' ORDER BY BILLNO DESC";
|
|
|
|
string strSql = " SELECT TOP 1 NO FROM ch_fee_recvamount WHERE NO LIKE '" + strFeeType + strDateTime + "%' ORDER BY NO DESC";
|
|
//+ " (SELECT NO FROM ch_fee_do WHERE NO LIKE '" + strFeeType + strDateTime + "%' UNION "
|
|
//+ " SELECT NO FROM ch_fee_recvamount WHERE NO LIKE '" + strFeeType + strDateTime + "%') as A ORDER BY NO DESC";
|
|
|
|
DataTable billTable = receiveAmountDA.GetExcuteSql(strSql).Tables[0];
|
|
|
|
ArrayList codeArg = new ArrayList();
|
|
|
|
for (int i = 0; i < CodeLength; i++)
|
|
{
|
|
codeArg.Add(0);
|
|
}
|
|
|
|
|
|
string strCode = "";//编号
|
|
|
|
if (billTable.Rows.Count > 0)
|
|
{
|
|
string oldCode = billTable.Rows[0][0].ToString();
|
|
|
|
if (oldCode.IndexOf(strCodePrefix) >= 0)
|
|
{
|
|
oldCode = oldCode.Substring(strCodePrefix.Length, oldCode.Length - strCodePrefix.Length);
|
|
|
|
|
|
if (oldCode.Length == CodeLength)
|
|
{
|
|
for (int i = 0; i < oldCode.Length; i++)
|
|
{
|
|
if (oldCode[i].ToString().IndexOf("0") == 0)
|
|
{
|
|
oldCode = oldCode.Remove(i, 1);
|
|
i = -1;
|
|
continue;
|
|
}
|
|
else
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
int newNum = int.Parse(oldCode);
|
|
|
|
newNum = newNum + 1;
|
|
|
|
string strNewNum = newNum.ToString();
|
|
|
|
int codeArgCount = codeArg.Count - 1;
|
|
for (int i = strNewNum.Length - 1; i >= 0; i--)
|
|
{
|
|
codeArg[codeArgCount] = strNewNum[i];
|
|
codeArgCount--;
|
|
}
|
|
//for (int i = 0; i < strNewNum.Length; i++)
|
|
//{
|
|
// codeArg[i] = strNewNum[i];
|
|
//}
|
|
|
|
}
|
|
else
|
|
{
|
|
int iOld = int.Parse(codeArg[codeArg.Count - 1].ToString());
|
|
codeArg[codeArg.Count - 1] = (iOld + 1).ToString();
|
|
}
|
|
|
|
for (int i = 0; i < codeArg.Count; i++)
|
|
{
|
|
strCode += codeArg[i].ToString();
|
|
}
|
|
|
|
strSettleCode = strFeeType + strDateTime + strCode;
|
|
return strSettleCode;
|
|
}
|
|
}
|
|
}
|