Exemplo n.º 1
0
        private void BuildPhotoLibrary(CONTRACT_FULL_VW cntrct)
        {
            // Initialize StringWriter instance.
            StringWriter stringWriter = new StringWriter();

            // Put HtmlTextWriter in using block because it needs to call Dispose.
            using (HtmlTextWriter writer = new HtmlTextWriter(stringWriter))
            {
                writer.RenderBeginTag(HtmlTextWriterTag.P); // Start of P
                for (int i = 1; i <= 5; i++)
                {
                    BuildPhotoData(writer, Convert.ToString(Helper.GetPropValue(cntrct, "PHOTO_" + i)), Convert.ToString(Helper.GetPropValue(cntrct, "THUMBNAIL_PHOTO_" + i)));
                }
                writer.RenderEndTag();  //End of P

                litPhoto.Text = stringWriter.ToString();
            }
        }
        private void BuildPhotoLibrary(CONTRACT_FULL_VW cntrct)
        {
            // Initialize StringWriter instance.
            StringWriter stringWriter = new StringWriter();

            // Put HtmlTextWriter in using block because it needs to call Dispose.
            using (HtmlTextWriter writer = new HtmlTextWriter(stringWriter))
            {
                writer.RenderBeginTag(HtmlTextWriterTag.P); // Start of P
                for (int i = 1; i <= 5; i++)
                {
                    BuildPhotoData(writer, Convert.ToString(Helper.GetPropValue(cntrct, "PHOTO_" + i)), Convert.ToString(Helper.GetPropValue(cntrct, "THUMBNAIL_PHOTO_" + i)));
                }
                writer.RenderEndTag();  //End of P

                litPhoto.Text = stringWriter.ToString();
            }
        }
Exemplo n.º 3
0
        protected override void Page_Load(object sender, EventArgs e)
        {
            base.Page_Load(sender, e);
            if (!IsPostBack)
            {
                try
                {
                    CommonList.LoadRentType(ddlRentType);
                    CommonList.LoadStore(ddlStore);
                    hdfFeeRate.Value = (GetFeeRate(Convert.ToInt32(Session["store_id"])) / 10000).ToString();
                    string id       = Request.QueryString["ID"];
                    string sId      = Request.QueryString["sID"];
                    string copy     = Request.QueryString["copy"];
                    int    STORE_ID = Convert.ToInt32(Session["store_id"]);

                    if (!string.IsNullOrEmpty(id) && string.IsNullOrEmpty(copy)) // EDIT
                    {
                        using (var db = new RentBikeEntities())
                        {
                            int contractId = Helper.parseInt(id);
                            var contract   = db.Contracts.FirstOrDefault(c => c.CONTRACT_STATUS == true && c.ID == contractId);

                            IsNewContract = false;
                            ContractID    = id;
                            List <CONTRACT_FULL_VW> lst;
                            int contractid = Convert.ToInt32(id);

                            Store stor = new Store();
                            stor = db.Stores.FirstOrDefault(s => s.ID == STORE_ID && s.ACTIVE == true);

                            var st = from s in db.CONTRACT_FULL_VW
                                     where s.ID == contractid && s.ACTIVE == true
                                     select s;

                            lst = st.ToList <CONTRACT_FULL_VW>();
                            ddlStore.SelectedValue = STORE_ID.ToString();

                            bool bDifferentSTORE_ID = false;
                            if (Helper.parseInt(sId) != STORE_ID)
                            {
                                if (!IS_ADMIN)
                                {
                                    bDifferentSTORE_ID = true;
                                }
                                STORE_ID = Helper.parseInt(sId);
                            }

                            ddlStore.SelectedValue = STORE_ID.ToString();
                            if (!IS_ADMIN)
                            {
                                ddlStore.Enabled = false;
                            }

                            if (!lst[0].CONTRACT_STATUS || (bDifferentSTORE_ID && !string.IsNullOrEmpty(Request.QueryString["sID"])))
                            {
                                pnlTable.Enabled          = false;
                                rptPayFeeSchedule.Visible = false;
                            }

                            CONTRACT_FULL_VW cntrct = lst[0];
                            txtLicenseNumber.Text      = cntrct.LICENSE_NO;
                            txtCustomerName.Text       = cntrct.CUSTOMER_NAME;
                            txtBirthDay.Text           = string.Format("{0:dd/MM/yyyy}", cntrct.BIRTH_DAY);
                            txtRangeDate.Text          = string.Format("{0:dd/MM/yyyy}", cntrct.LICENSE_RANGE_DATE);
                            txtPlaceDate.Text          = cntrct.LICENSE_RANGE_PLACE;
                            txtPhone.Text              = cntrct.PHONE;
                            txtPermanentResidence.Text = cntrct.PERMANENT_RESIDENCE;
                            txtCurrentResidence.Text   = cntrct.CURRENT_RESIDENCE;
                            txtContractNo.Text         = cntrct.CONTRACT_NO;
                            var rentType = db.RentTypes.Where(c => c.NAME == cntrct.RENT_TYPE_NAME).FirstOrDefault();
                            ddlRentType.SelectedValue = rentType.ID.ToString();
                            RentTypeID        = cntrct.RENT_TYPE_ID;
                            txtAmount.Text    = string.Format("{0:0,0}", cntrct.CONTRACT_AMOUNT);
                            txtFeePerDay.Text = string.Format("{0:0,0}", cntrct.FEE_PER_DAY);
                            txtRentDate.Text  = string.Format("{0:dd/MM/yyyy}", cntrct.RENT_DATE);
                            txtEndDate.Text   = string.Format("{0:dd/MM/yyyy}", cntrct.END_DATE);
                            txtNote.Text      = cntrct.NOTE;

                            txtReferencePerson.Text = cntrct.REFERENCE_NAME;
                            txtItemName.Text        = cntrct.ITEM_TYPE;
                            txtItemLicenseNo.Text   = cntrct.ITEM_LICENSE_NO;
                            txtSerial1.Text         = cntrct.SERIAL_1;
                            txtSerial2.Text         = cntrct.SERIAL_2;
                            txtImplementer.Text     = cntrct.IMPLEMENTER;
                            txtBackDocument.Text    = cntrct.BACK_TO_DOCUMENTS;
                            txtItemDetail.Text      = cntrct.DETAIL;
                            txtReferencePhone.Text  = cntrct.REFERENCE_PHONE;
                            txtSchool.Text          = cntrct.SCHOOL_NAME;
                            txtClass.Text           = cntrct.CLASS_NAME;

                            Customer customer = db.Customers.FirstOrDefault(c => c.ID == cntrct.CUSTOMER_ID);
                            if (customer != null)
                            {
                                if (customer.IS_LOW_RECOVERABILITY)
                                {
                                    btnLowRecoverability.Text            = "Bỏ khả năng thu hồi thấp";
                                    btnLowRecoverability.CommandArgument = "RevertLowRecoverability";
                                }
                            }

                            BuildPhotoLibrary(cntrct);

                            ddlStore.Enabled = txtContractNo.Enabled = txtRentDate.Enabled = txtEndDate.Enabled = false;

                            LoadPayFeeSchedule();
                        }
                    }
                    else // NEW
                    {
                        //Remove [rent other] option if user is just staff
                        if (PERMISSION == ROLE.STAFF)
                        {
                            ddlRentType.Items.Remove(ddlRentType.Items[ddlRentType.Items.Count - 1]);
                        }

                        IsNewContract             = true;
                        btnFinishContract.Visible = false;
                        txtContractNo.Visible     = false;
                        using (var db = new RentBikeEntities())
                        {
                            if (!IS_ADMIN)
                            {
                                ddlStore.SelectedValue = STORE_ID.ToString();
                                ddlStore.Enabled       = false;
                            }
                            RentTypeID       = Convert.ToInt32(ddlRentType.SelectedValue);
                            txtRentDate.Text = string.Format("{0:dd/MM/yyyy}", DateTime.Now);
                            txtEndDate.Text  = string.Format("{0:dd/MM/yyyy}", DateTime.Now.AddDays(29));

                            if (!string.IsNullOrEmpty(id) && !string.IsNullOrEmpty(copy))
                            {
                                int contractid          = Convert.ToInt32(id);
                                CONTRACT_FULL_VW cntrct = db.CONTRACT_FULL_VW.Where(s => s.ID == contractid && s.ACTIVE == true).FirstOrDefault();
                                if (cntrct != null)
                                {
                                    if (IS_ADMIN)
                                    {
                                        STORE_ID = cntrct.STORE_ID;
                                    }
                                    else
                                    {
                                        ddlStore.Enabled = false;
                                    }

                                    ddlStore.SelectedValue = STORE_ID.ToString();

                                    txtLicenseNumber.Text      = cntrct.LICENSE_NO;
                                    txtCustomerName.Text       = cntrct.CUSTOMER_NAME;
                                    txtBirthDay.Text           = string.Format("{0:dd/MM/yyyy}", cntrct.BIRTH_DAY);
                                    txtRangeDate.Text          = string.Format("{0:dd/MM/yyyy}", cntrct.LICENSE_RANGE_DATE);
                                    txtPlaceDate.Text          = cntrct.LICENSE_RANGE_PLACE;
                                    txtPhone.Text              = cntrct.PHONE;
                                    txtPermanentResidence.Text = cntrct.PERMANENT_RESIDENCE;
                                    txtCurrentResidence.Text   = cntrct.CURRENT_RESIDENCE;
                                    txtContractNo.Text         = cntrct.CONTRACT_NO;
                                    var rentType = db.RentTypes.Where(c => c.NAME == cntrct.RENT_TYPE_NAME).FirstOrDefault();
                                    ddlRentType.SelectedValue = rentType.ID.ToString();
                                    RentTypeID        = cntrct.RENT_TYPE_ID;
                                    txtAmount.Text    = string.Format("{0:0,0}", cntrct.CONTRACT_AMOUNT);
                                    txtFeePerDay.Text = string.Format("{0:0,0}", cntrct.FEE_PER_DAY);
                                    txtNote.Text      = cntrct.NOTE;

                                    txtReferencePerson.Text = cntrct.REFERENCE_NAME;
                                    txtItemName.Text        = cntrct.ITEM_TYPE;
                                    txtItemLicenseNo.Text   = cntrct.ITEM_LICENSE_NO;
                                    txtSerial1.Text         = cntrct.SERIAL_1;
                                    txtSerial2.Text         = cntrct.SERIAL_2;
                                    txtImplementer.Text     = cntrct.IMPLEMENTER;
                                    txtBackDocument.Text    = cntrct.BACK_TO_DOCUMENTS;
                                    txtItemDetail.Text      = cntrct.DETAIL;
                                    txtReferencePhone.Text  = cntrct.REFERENCE_PHONE;
                                    txtSchool.Text          = cntrct.SCHOOL_NAME;
                                    txtClass.Text           = cntrct.CLASS_NAME;

                                    BuildPhotoLibrary(cntrct);
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    lblMessage.Text     = ex.Message;
                    lblMessage.CssClass = "text-center text-danger";
                }
            }

            //Disable UI for Admin account
            if (IS_ADMIN)
            {
                pnlTable.Enabled = false;
            }
        }