/// <summary>
        /// Update
        /// </summary>
        private void UpdateData()
        {
            Mst_BuildingData data = new Mst_BuildingData();
            ITransaction tran = factory.GetLoadObject(data, txtBuildingId.Text.Trim());
            Execute(tran);
            if (!HasError)
            {
                //Get Data
                data = (Mst_BuildingData)tran.Result;

                data.BuildingId = txtBuildingId.Text.Trim();
                data.Name = txtName.Text.Trim();
                data.Investor = txtInvestor.Text.Trim();
                data.Address = txtAddress.Text.Trim();
                data.Phone = txtPhone.Text.Trim();
                data.Owner = txtOwner.Text.Trim();
                data.ManagerCompany = txtManagerCompany.Text.Trim();
                data.ManagerCompanyAgent = txtManagerCompanyAgent.Text.Trim();
                data.ManagerCompanyPhone = txtManagerCompanyPhone.Text.Trim();

                data.Comment = txtComment.Text.Trim();

                data.Bank = txtBank.Text.Trim();
                data.Account = txtAccount.Text.Trim();
                data.AccountName = txtAccountName.Text.Trim();
                data.Office = txtOffice.Text.Trim();
                data.OfficePhone = txtOfficePhone.Text.Trim();

                data.ModifiedBy = Page.User.Identity.Name;
                data.Modified = DateTime.Now.ToString("yyyyMMddHHmmss");
                data.DelFlag = true.Equals(chkDelFlag.Checked) ? "0" : "1";

                tran = factory.GetUpdateObject(data);

                Execute(tran);

                if (!HasError)
                {
                    OperationLogger.WriteInfo(Constants.LogOperationAlbumId, Constants.LogActionUpdateId, updateSuccess, Page.User.Identity.Name);
                    mvMessage.SetCompleteMessage(updateSuccess);
                    ScriptManager.RegisterClientScriptBlock(this.btnRegister, this.GetType(), key, postback, true);

                    lblCreated.Text = !"".Equals(data.Created) ? data.CreatedBy + "(" + Func.Formatdmyhms(data.Created) + ")" : "";
                    lblModified.Text = !"".Equals(data.Modified) ? data.ModifiedBy + "(" + Func.Formatdmyhms(data.Modified) + ")" : "";
                }
                else
                {
                    OperationLogger.WriteError(Constants.LogOperationAlbumId, Constants.LogActionUpdateId, updateUnSuccess, Page.User.Identity.Name);
                    mvMessage.AddError(updateUnSuccess);
                }
            }
        }
        /// <summary>
        /// Load data
        /// </summary>
        private void LoadData()
        {
            Mst_BuildingData data = new Mst_BuildingData();
            ITransaction tran = factory.GetLoadObject(data, txtBuildingId.Text.Trim());
            Execute(tran);
            if (!HasError)
            {
                //Get Data
                data = (Mst_BuildingData)tran.Result;
                txtName.Text = data.Name;
                txtComment.Text = data.Comment;
                chkDelFlag.Checked = "1".Equals(data.DelFlag) ? false : true;

                txtBuildingId.Text = data.BuildingId;
                txtName.Text = data.Name;
                txtInvestor.Text = data.Investor;
                txtAddress.Text = data.Address;
                txtPhone.Text = data.Phone;
                txtOwner.Text = data.Owner;
                txtManagerCompany.Text = data.ManagerCompany;
                txtManagerCompanyAgent.Text = data.ManagerCompanyAgent;
                txtManagerCompanyPhone.Text = data.ManagerCompanyPhone;

                txtBank.Text = data.Bank;
                txtAccount.Text = data.Account;
                txtAccountName.Text = data.AccountName;
                txtOffice.Text = data.Office;
                txtOfficePhone.Text = data.OfficePhone;

                lblCreated.Text = !"".Equals(data.Created) ? data.CreatedBy + "(" + Func.Formatdmyhms(data.Created) + ")" : "";
                lblModified.Text = !"".Equals(data.Modified) ? data.ModifiedBy + "(" + Func.Formatdmyhms(data.Modified) + ")" : "";
            }
        }
Exemple #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                PopupWidth = 850;
                PopupHeight = 450;
                ShowData();

                Mst_BuildingData data = new Mst_BuildingData();
                ITransaction tran = factory.GetLoadObject(data, Func.ParseString(Session["__BUILDINGID__"]));
                Execute(tran);
                if (!HasError)
                {
                    //Get Data
                    data = (Mst_BuildingData)tran.Result;
                    lblName.Text = data.Name;
                    lblComment.Text = data.Comment;
                    lblBuildingId.Text = data.BuildingId;
                    lblName.Text = data.Name;
                    lblInvestor.Text = data.Investor;
                    lblAddress.Text = data.Address;
                    lblPhone.Text = data.Phone;
                    lblOwner.Text = data.Owner;
                    lblManagerCompany.Text = data.ManagerCompany;
                    lblManagerCompanyAgent.Text = data.ManagerCompanyAgent;
                    lblManagerCompanyPhone.Text = data.ManagerCompanyPhone;
                }
            }
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnAutoId_Click(object sender, EventArgs e)
        {
            Mst_BuildingData data = new Mst_BuildingData();

            string prefix = "BD";
            int length = 5;
            string tmp = String.Format("", length);

            string sql = "SELECT max(maxid) from (SELECT SUBSTRING(BuildingId, " + (prefix.Length + 1) + ", " + length + ") as maxid FROM Mst_Building) as tmp WHERE maxid < '100'";

            int key = 0;
            try
            {
                key = Convert.ToInt32(DbHelper.GetScalar(sql));
                key++;
            }
            catch
            {
                key = 1;
            }

            bool keyFlg = true;
            while (keyFlg)
            {
                string tmpKey = prefix + key.ToString().PadLeft(length - prefix.Length, '0');
                sql = "SELECT count(*) from Mst_Building WHERE BuildingId = '" + tmpKey + "'";
                if (Convert.ToInt32(DbHelper.GetScalar(sql)) != 1)
                {
                    keyFlg = false;
                }
                else
                {
                    key--;
                }
            }
            txtAutoId.Text = prefix + key.ToString().PadLeft(length - prefix.Length, '0');
        }
Exemple #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            hidId.Value = Func.ParseString(Request["id"]);
            hidYearMonth.Value = Func.ParseString(Request["yearmonth"]);

            if (!IsPostBack)
            {
                txtCustomerId.Text = hidId.Value;
                hidBillId.Value = DbHelper.GetScalar("Select id from PaymentBillInfo where customerid = '" + hidId.Value + "' and YearMonth = '" + hidYearMonth.Value + "' and BuildingId= '" + Func.ParseString(Session["__BUILDINGID__"]) + "'");
                if (Func.ParseInt(hidBillId.Value) > 0)
                {
                    PaymentBillInfoData data = new PaymentBillInfoData();
                    ITransaction tran = factory.GetLoadObject(data, hidBillId.Value);
                    Execute(tran);
                    if (!HasError)
                    {
                        data = (PaymentBillInfoData)tran.Result;
                        txtName.Text = data.Name;
                        txtContactName.Text = data.ContactName;
                        txtBank.Text = data.Bank;
                        txtAccount.Text = data.Account;
                        txtAccountName.Text = data.AccountName;
                        txtOffice.Text = data.Office;
                        txtOfficePhone.Text = data.OfficePhone;
                        txtBillDate.Text = data.BillDate;
                        txtUsdExchangeDate.Text = Func.FormatDMY(data.UsdExchangeDate);
                        txtUsdExchange.Text = data.UsdExchange;
                    }
                }

                if (String.IsNullOrEmpty(hidBillId.Value))
                {
                    CustomerData data = new CustomerData();
                    ITransaction tran = factory.GetLoadObject(data, hidId.Value);
                    Execute(tran);
                    if (!HasError)
                    {
                        //Get Data
                        data = (CustomerData)tran.Result;
                        txtCustomerId.Text = data.CustomerId;
                        txtName.Text = data.Name;
                        //txtComment.Text = data.Comment;
                        txtContactName.Text = data.ContactName;
                    }

                    Mst_BuildingData dataB = new Mst_BuildingData();
                    ITransaction tranB = factory.GetLoadObject(dataB, Func.ParseString(Session["__BUILDINGID__"]));
                    Execute(tranB);
                    if (!HasError)
                    {
                        //Get Data
                        dataB = (Mst_BuildingData)tranB.Result;
                        txtBank.Text = dataB.Bank;
                        txtAccount.Text = dataB.Account;
                        txtAccountName.Text = dataB.AccountName;
                        txtOffice.Text = dataB.Office;
                        txtOfficePhone.Text = dataB.OfficePhone;
                    }
                }
            }
        }