Ejemplo n.º 1
0
 protected void bSaveAccountablePerson_Click(object sender, EventArgs e)
 {
     try
     {
         AccountablePersonData apd = fillFromForm();
         if (gvAccountablePersons.Rows.Count > 0)
         {
             int id = Convert.ToInt32(gvAccountablePersons.DataKeys[gvAccountablePersons.SelectedIndex].Values["id"]);
             AccountablePersonData apds = db.getAccountablePersonData(id);
             for (int i = 0; i < apd.accountdata.Length; i++)
             {
                 AccountablePersonAccountData apad = apds.accountdata.FirstOrDefault(r => r.id > 0 && r.product_type_enum == apd.accountdata[i].product_type_enum &&
                                                                                     r.account_type_enum == apd.accountdata[i].account_type_enum &&
                                                                                     r.issafe == apd.accountdata[i].issafe);
                 if (apad != null)
                 {
                     apd.accountdata[i].id = apad.id;
                 }
             }
             apd.id = id;
         }
         int idBranch = sc.BranchId(Page.User.Identity.Name);
         db.saveAccountablePersonData(apd, idBranch);
         RefreshList(gvAccountablePersons.SelectedIndex);
         selectID();
     }
     catch (Exception e1)
     {
         ClientScript.RegisterClientScriptBlock(GetType(), "bSave_ReClick", "<script type='text/javascript'>$(document).ready(function(){ " +
                                                "clickEdit(); ShowError('" + System.Security.SecurityElement.Escape(e1.Message) + "'); });</script>");
     }
 }
Ejemplo n.º 2
0
        public AccountablePersonData getAccountablePersonData(int id, SqlTransaction trans = null)
        {
            AccountablePersonData apd = new AccountablePersonData();

            if (id != 0)
            {
                SqlCommand cmdSelect = new SqlCommand(string.Format("select a.*, UserName, b.id as UserId from AccountablePerson a left join aspnet_Users b on a.UserId=b.id where a.id = {0}", id), conn);
                cmdSelect.Transaction = trans;
                using (SqlDataReader dr = cmdSelect.ExecuteReader())
                {
                    if (dr.HasRows)
                    {
                        dr.Read();
                        apd.id         = Convert.ToInt32(dr["id"]);
                        apd.secondname = (string)dr["secondname"];
                        apd.firstname  = (string)dr["firstname"];
                        if (dr["patronymic"] != DBNull.Value)
                        {
                            apd.patronymic = (string)dr["patronymic"];
                        }
                        if (dr["birthday"] != DBNull.Value)
                        {
                            apd.birthday = Convert.ToDateTime(dr["birthday"]);
                        }
                        if (dr["position"] != DBNull.Value)
                        {
                            apd.position = (string)dr["position"];
                        }
                        if (dr["passport"] != DBNull.Value)
                        {
                            apd.passport = (string)dr["passport"];
                        }
                        if (dr["dateissue"] != DBNull.Value)
                        {
                            apd.dateissue = Convert.ToDateTime(dr["dateissue"]);
                        }
                        if (dr["issuedby"] != DBNull.Value)
                        {
                            apd.issuedby = (string)dr["issuedby"];
                        }
                        if (dr["UserName"] != DBNull.Value)
                        {
                            apd.userLogin = (string)dr["UserName"];
                        }
                        if (dr["UserId"] != DBNull.Value)
                        {
                            apd.userId = (int)dr["UserId"];
                        }
                        apd.personnelnumber = (string)dr["personnelnumber"];
                        apd.active          = Convert.ToBoolean(dr["active"]);
                    }
                    else
                    {
                        throw new Exception("getAccountablePersonData: запись с идентификатором " + id.ToString() + " не найдена");
                    }
                }
                cmdSelect = new SqlCommand(string.Format("select * from AccountablePersonAccount where id_accountableperson = {0}", apd.id), conn);
                using (SqlDataReader dr = cmdSelect.ExecuteReader())
                {
                    if (dr.HasRows)
                    {
                        while (dr.Read() == true)
                        {
                            AccountablePersonAccountData apad = apd.accountdata.FirstOrDefault(r => r.product_type_enum == Convert.ToInt32(dr["product_type_enum"]) &&
                                                                                               r.account_type_enum == Convert.ToInt32(dr["account_type_enum"]) &&
                                                                                               r.issafe == Convert.ToBoolean(dr["issafe"]));
                            if (apad != null)
                            {
                                apad.id = Convert.ToInt32(dr["id"]);
                                apad.id_accountableperson = Convert.ToInt32(dr["id_accountableperson"]);
                                apad.account_debet        = (string)dr["account_debet"];
                                apad.account_credit       = (string)dr["account_credit"];
                            }
                        }
                    }
                }
            }
            return(apd);
        }
Ejemplo n.º 3
0
 protected TextBox getControlCredit(AccountablePersonAccountData aData)
 {
     return(getControl(null, getDefaultName(aData) + "_Credit"));
 }
Ejemplo n.º 4
0
 protected string getDefaultName(AccountablePersonAccountData aData)
 {
     return(((BaseProductType)(aData.product_type_enum)).ToString() + "_" + ((AccountBranchType)(aData.account_type_enum)).ToString() + "_" + aData.issafe.ToString());
 }
Ejemplo n.º 5
0
        public AccountablePersonData()
        {
            accountdata = new AccountablePersonAccountData[(Enum.GetNames(typeof(BaseProductType)).Length - 1) * COUNTOPERATION];

            secondname      = "";
            firstname       = "";
            patronymic      = "";
            birthday        = DateTime.MinValue;
            position        = "";
            passport        = "";
            dateissue       = DateTime.MinValue;
            issuedby        = "";
            personnelnumber = "";
            active          = true;
            userLogin       = "";
            userId          = 0;

            foreach (var value in Enum.GetValues(typeof(BaseProductType)))
            {
                if ((int)value == 0)
                {
                    continue;
                }
                int index = ((int)value) - 1;
                for (int i = 0; i < COUNTOPERATION; i++)
                {
                    accountdata[index * COUNTOPERATION + i] = new AccountablePersonAccountData();
                    AccountablePersonAccountData ad = accountdata[index * COUNTOPERATION + i];
                    ad.product_type_enum = (int)value;
                    if (i < 2)
                    {
                        if (i == 1)
                        {
                            ad.account_credit = ACCOUNTSAFE;
                            ad.issafe         = true;
                        }
                        else
                        {
                            ad.account_credit = ACCOUNTSTORAGE;
                            ad.issafe         = false;
                        }
                        ad.account_debet     = "91203???????????????";
                        ad.account_type_enum = (int)AccountBranchType.In;
                    }
                    if (i == 2)
                    {
                        ad.account_credit    = "91203???????????????";
                        ad.account_debet     = ACCOUNTCLIENT;
                        ad.issafe            = false;
                        ad.account_type_enum = (int)AccountBranchType.Out;
                    }
                    if (i > 2 && i < 5)
                    {
                        if (i == 4)
                        {
                            ad.account_debet = ACCOUNTSAFE;
                            ad.issafe        = true;
                        }
                        else
                        {
                            ad.account_debet = ACCOUNTSTORAGE;
                            ad.issafe        = false;
                        }
                        ad.account_credit    = "91203???????????????";
                        ad.account_type_enum = (int)AccountBranchType.Return;
                    }
                }
            }
        }