コード例 #1
0
 protected void btnNext_Click(object sender, EventArgs e)
 {
     if (lblId.Text == string.Empty) return;
     int shoptId = int.Parse(lblId.Text);
     int id = new Shop().GetNextShopId(shoptId);
     Response.Redirect("ShopInfo.aspx?id=" + id.ToString(), true);
     //if (id > 0) ShowTenantDetails(id);
 }
コード例 #2
0
        protected void btnGenerate_Click(object sender, EventArgs e)
        {
            StringBuilder strSuccess=new StringBuilder();
            StringBuilder strFailure = new StringBuilder();

            strSuccess.Append("<strong>Success</strong><br>");
            strFailure.Append("<strong>Failure</strong><br>");

            try
            {
                if (ddlMarket.SelectedIndex <= 0)
                {
                    Alert.Show("Please select a market first.");
                    ddlMarket.Focus();
                    return;
                }

                int marketId = int.Parse(ddlMarket.SelectedValue);
                List<Shop> shopList = new Shop().GetAllShopByMarketId(marketId);
                BillMaster billMaster = new BillMaster();
                BillDetail billDetail = new BillDetail();

                foreach (ListItem li in cbListShops.Items)
                {
                    if (!li.Selected) continue;

                    int shopId = int.Parse(li.Value);

                    Shop shop = shopList.Find(x => x.Id == shopId);
                    try
                    {
                        #region process bill master data

                        string monthYearText = ddlMonth.SelectedItem.Text;
                        string monthYearVal = ddlMonth.SelectedValue;

                        ShopeMapping shopeMapping = new ShopeMapping().GetAllShopeMappingByShopId(shop.Id);

                        billMaster.BilGeneratelDate = DateTime.Parse(txtDate.Text);
                        billMaster.BillMonth = monthYearText.Substring(5);
                        billMaster.BillYear = int.Parse(monthYearText.Substring(0, 4));
                        billMaster.TenantId = shopeMapping.TenantId;

                        billMaster.BillNo = billMaster.BillYear + "-" + monthYearVal.Substring(5) + "-" +
                                            shop.Id + "-" + shopeMapping.TenantId;

                        billMaster.GenerateBy = 1;
                        billMaster.ApprovedBy = 0;
                        billMaster.TotalAmount = 0;
                        billMaster.TotalPayment = 0;
                        billMaster.LastPaymentDate = (DateTime) dtpLastDate.SelectedDate;

                        string MonthVal = ddlMonth.SelectedValue.Substring(5);
                        billMaster.BillMonthId = int.Parse(MonthVal);
                        int success = 0;

                        int billId = billMaster.CheckExistanceByBillNo(billMaster.BillNo);
                        if (billId > 0)
                        {
                            if (!chkUpdateExisting.Checked)
                            {
                                strFailure.Append("Bill already generated for the shop: " + shop.ShopNo + "<br>");
                                continue;
                            }

                            billMaster.Id = billId;
                            success = billMaster.UpdateBillMaster();
                        }
                        else
                        {
                            success = billMaster.InsertBillMaster();
                            billMaster.Id = new BillMaster().GetLastId();
                        }

                    #endregion

                        #region process bill detail data

                        if (success > 0)
                        {
                            billDetail = new BillDetail();
                            billDetail.BillMasterId = billMaster.Id;
                            billDetail.MarketId = int.Parse(ddlMarket.SelectedValue);
                            billDetail.ShopId = shop.Id;
                            billDetail.MonthlyRent = shopeMapping.MonthlyRent;
                            billDetail.ServiceCharge = shopeMapping.ServiceCharge;
                            billDetail.MiscBills = shopeMapping.MiscBill;

                            if (chkPrevDue.Checked)
                            {
                                DueInstallment installment = new DueInstallment().GetDueInstallmentByTenant(billMaster.TenantId);
                                if (installment.Id != 0)
                                {
                                    billDetail.PreviousDue = installment.InstallmentAmount;
                                    if (installment.DueAmount < installment.InstallmentAmount)
                                        billDetail.PreviousDue = installment.DueAmount;
                                }
                                else
                                {
                                    if (billDetail.CheckBillExistenceByTenant(billMaster.TenantId, shop.Id) > 0)
                                        billDetail.PreviousDue = billDetail.GetLastDueTenantAndShopWise(billMaster.TenantId, shop.Id);
                                    else
                                        billDetail.PreviousDue = new ShopeMapping().GetAllShopeMappingByShopId(shop.Id).PreviousDue;
                                }

                            }
                            else
                                billDetail.PreviousDue = 0;

                            billDetail.LateFee = Math.Round((shopeMapping.MonthlyRent*5)/100,0);
                            billDetail.Payment = 0;
                            billDetail.IsClosed = false;
                            billDetail.ClosedBy = 0;

                            if (billId > 0)
                            {
                                int billDetailId = billDetail.GetBillDetailIdByMasterId(billId);
                                if (billDetailId > 0)
                                {
                                    billDetail.Id = billDetailId;
                                    success = billDetail.UpdateBillDetail();
                                }
                                else
                                    success = billDetail.InsertBillDetail();
                            }
                            else
                                success = billDetail.InsertBillDetail();

                            //update total amount in master table
                            if (success > 0)
                            {
                                decimal totalAmount = (billDetail.MonthlyRent + billDetail.ServiceCharge +
                                                       billDetail.MiscBills +
                                                       billDetail.PreviousDue);

                                billMaster.UpdateTotalAmount(billMaster.Id, totalAmount);

                                strSuccess.Append("Bill generated for Shop: " + shop.ShopNo + "<br>");
                            }
                        }

                        #endregion

                    }

                    catch (Exception ex)
                    {
                        strFailure.Append("Bill generate failed for Shop " + shop.ShopNo + ". Error: " + ex.Message +
                                          "<br>");
                        continue;
                    }
                }

                strFailure.Append("<br><br>");

                ltrStatus.Text = strFailure.ToString() + strSuccess.ToString();
            }
            catch (Exception ex)
            {

                Alert.Show(ex.Message);
            }
        }
コード例 #3
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (ddlMarket.SelectedIndex == -1)
                {
                    Alert.Show("দয়া করে মার্কেট নির্ধারণ করুন।");
                    ddlMarket.Focus();
                    return;
                }
                if (txtShopNo.Text==string.Empty)
                {
                    Alert.Show("দয়া করে দোকান/কক্ষ নং প্রদান করুন।");
                    txtShopNo.Focus();
                    return;
                }

                //convert unicode to decimal
                string strMonthlyRent = Encode.HtmlEncode(txtMonthlyRent.Text);
                decimal decMonthlyRent = 0;
                try
                {
                    decMonthlyRent = decimal.Parse(strMonthlyRent);
                }
                catch (Exception ex)
                {
                    Alert.Show("দয়া করে সার্ভিস চার্জ ফিল্ডে শুধুমাত্র নাম্বার প্রবেশ করুন।");
                    txtMonthlyRent.Focus();
                    return;
                }

                string strServcieCharge = Encode.HtmlEncode(txtServiceCharge.Text);
                decimal decServiceCharge = 0;
                try
                {
                    decServiceCharge = decimal.Parse(strServcieCharge);
                }
                catch (Exception ex)
                {
                    Alert.Show("দয়া করে সার্ভিস চার্জ ফিল্ডে শুধুমাত্র নাম্বার প্রবেশ করুন।");
                    txtServiceCharge.Focus();
                    return;
                }

                string strMiscBill = Encode.HtmlEncode(txtMiscBill.Text);
                decimal decMiscBill  = 0;
                try
                {
                    decMiscBill = decimal.Parse(strMiscBill);
                }
                catch (Exception ex)
                {
                    Alert.Show("দয়া করে বিবিধ বিল ফিল্ডে শুধুমাত্র নাম্বার প্রবেশ করুন।");
                    txtMiscBill.Focus();
                    return;
                }

                string strAdvance = Encode.HtmlEncode(txtAdvance.Text);
                decimal decAdvance = 0;
                try
                {
                    decAdvance = decimal.Parse(strAdvance);
                }
                catch (Exception ex)
                {
                    Alert.Show("দয়া করে সার্ভিস চার্জ ফিল্ডে শুধুমাত্র নাম্বার প্রবেশ করুন।");
                    txtAdvance.Focus();
                    return;
                }

                string strSqFeet= Encode.HtmlEncode(txtArea.Text);
                decimal decSqFeet = 0;
                try
                {
                    decSqFeet = decimal.Parse(strSqFeet);
                }
                catch (Exception ex)
                {
                    Alert.Show("দয়া করে জায়গার পরিমাপ ফিল্ডে শুধুমাত্র নাম্বার প্রবেশ করুন।");
                    txtArea.Focus();
                    return;
                }

                Shop obj=new Shop();

                obj.MarketId = int.Parse(ddlMarket.SelectedValue);
                obj.ShopNo = txtShopNo.Text;
                obj.SpaceInSqFt = decSqFeet;
                obj.MonthlyRent = decMonthlyRent;
                obj.ServiceCharge = decServiceCharge;
                obj.MiscBill = decMiscBill;
                obj.AdvanceAmount = decAdvance;
                obj.ShopType = ddlShopType.SelectedItem.Text;
                obj.CategoryId = int.Parse(ddlShopType.SelectedValue);
                obj.Description = txtDescription.Text;

                if (!isNewEntry)
                    obj.Id = int.Parse(lblId.Text);

                int count = obj.CheckShopNoExistance(isNewEntry);
                if (count > 0)
                {
                    Alert.Show("This shop no is already exist. Please enter a unique shop no.");
                    txtShopNo.Focus();
                    return;
                }

                int success = 0;

                if (isNewEntry)
                    success = obj.InsertShop();
                else
                    success = obj.UpdateShop();

                if (success == 1)
                {
                    Alert.Show("তথ্য সংরক্ষণ হয়েছে।");

                    if (isNewEntry)
                    {
                        lblId.Text = obj.GetLastShopId().ToString();
                        isNewEntry = false;
                    }
                }
            }
            catch (Exception ex)
            {
               Alert.Show(ex.Message);
            }
        }
コード例 #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (!IsValidSession())
                {
                    string str = Request.QueryString.ToString();
                    if (str == string.Empty)
                        Response.Redirect("LogIn.aspx?refPage=default.aspx");
                    else
                        Response.Redirect("LogIn.aspx?refPage=default.aspx?" + str);
                }

                if (!IsPostBack)
                {
                    userId = 1;
                    isNewEntry = true;

                    this.Clear();
                    this.LoadShopCategory();
                    this.LoadMarketDropDown();

                    if (Request.QueryString["id"] != null)
                    {
                        int id = int.Parse(Request.QueryString["id"].ToString());

                        if (id > 0)
                        {
                            Shop shop = new Shop().GetShopById(id);

                            lblId.Text = shop.Id.ToString();
                            txtShopNo.Text = shop.ShopNo;
                            txtServiceCharge.Text = shop.ServiceCharge.ToString();
                            txtMonthlyRent.Text = shop.MonthlyRent.ToString();
                            txtDescription.Text = shop.Description;
                            txtArea.Text = Math.Round(shop.SpaceInSqFt,0).ToString();
                            txtAdvance.Text = shop.AdvanceAmount.ToString();
                            ddlShopType.SelectedValue = shop.CategoryId.ToString();
                            ddlMarket.SelectedValue = shop.MarketId.ToString();
                            txtMiscBill.Text = shop.MiscBill.ToString();

                            isNewEntry = false;
                            btnNext.Visible = true;
                            btnPrev.Visible = true;
                        }
                    }
                }
            }
            catch (Exception ex)
            {

                Alert.Show(ex.Message);
            }
        }
コード例 #5
0
        private void LoadUnallocatedShopDropDown(int marketId)
        {
            if (marketId == 0) return;

            List<Shop> objShopList = new List<Shop>();
            Shop objShop = new Shop();
            objShopList = objShop.GetAllUnallocatedShopByMarketId(marketId);

            objShopList.Insert(0, objShop);

            ddlShop.DataTextField = "ShopNo";
            ddlShop.DataValueField = "Id";

            ddlShop.DataSource = objShopList;
            ddlShop.DataBind();

            ddlShop.SelectedIndex = -1;
        }
コード例 #6
0
        protected void ddlShop_SelectedIndexChanged(object sender, DropDownListEventArgs e)
        {
            if (ddlShop.SelectedIndex > 0)
            {
                int shopId = int.Parse(ddlShop.SelectedValue);

                Shop shop = new Shop().GetShopById(shopId);

                txtMonthlyRent.Text = shop.MonthlyRent.ToString();
                txtServiceCharge.Text = shop.ServiceCharge.ToString();
                txtAdvance.Text = shop.AdvanceAmount.ToString();

            }
        }
コード例 #7
0
        private void LoadGrid(int marketId)
        {
            try
            {
                List<Shop> shops = new List<Shop>();

                if(marketId == 0)
                    shops= new Shop().GetAllShop();
                else
                    shops = new Shop().GetAllShopByMarketIdWithoutTenant(marketId);

                RadGrid1.DataSource = shops;
                RadGrid1.DataBind();
            }
            catch (Exception ex)
            {
                Alert.Show("Error in method 'LoadLeaveDetailsGrid'. Error: " + ex.Message);
            }
        }