Exemplo n.º 1
0
        public ActionResult SaveCustomerCollectionAdjustmentForUpdateNDelete(FormCollection fCollection)
        {
            try
            {
                objLoginHelper = (LoginHelper)Session["LogInInformation"];

                byte   entrySerialNo = Convert.ToByte(fCollection["hfCollectionSerialsForUpdateNDelete"]);
                string yearMonth     = fCollection["hfCollectionYearMonthForUpdateNDelete"];
                string yearMonth1    = fCollection["dtpCollectionDateForUpdateNDelete"].ToString();

                Sal_CollectionFromCustomers objCollectionFromCustomers = new Sal_CollectionFromCustomers();

                objCollectionFromCustomers = salesDal.ReadCollectionFromCustomers(fCollection["hfCustomerCodeForCollectionForUpdateNDelete"], yearMonth, Convert.ToByte(fCollection["hfCollectionSerialsForUpdateNDelete"]));

                objCollectionFromCustomers.CustomerCode = fCollection["hfCustomerCodeForCollectionForUpdateNDelete"];
                objCollectionFromCustomers.YearMonth    = yearMonth; //Helper.ConvertDateToYearMonth(Convert.ToDateTime(yearMonth1));
                objCollectionFromCustomers.SerialNo     = entrySerialNo;
                if (fCollection["hfCustomerCollectionTypeForUpdateNDelete"].Trim() == "Installment/Overdue Collection Amount")
                {
                    objCollectionFromCustomers.CollectionType = Helper.CollectionTypeIOC;
                }
                else
                {
                    objCollectionFromCustomers.CollectionType = Helper.CollectionTypeAAA;
                }
                objCollectionFromCustomers.CollectionAmount = Convert.ToDecimal(fCollection["txtCollectionAmountForUpdateNDelete"]);
                objCollectionFromCustomers.CollectionDate   = Convert.ToDateTime(fCollection["dtpCollectionDateForUpdateNDelete"]);

                if (!string.IsNullOrEmpty(fCollection["txtMemoNumberForUpdateNDelete"]))
                {
                    objCollectionFromCustomers.RefMemoNo = fCollection["txtMemoNumberForUpdateNDelete"];

                    string firstCharacterOfCashMemo = objCollectionFromCustomers.RefMemoNo.Trim().Substring(0, 1);

                    if (firstCharacterOfCashMemo.ToUpper() == "A")
                    {
                        objCollectionFromCustomers.CashMemoNo     = objCollectionFromCustomers.RefMemoNo;
                        objCollectionFromCustomers.CashMemoUsesID = Helper.CashMemuUsesIdFirst;
                        objCollectionFromCustomers.RefMemoNo      = null;
                    }
                }

                else
                {
                    objCollectionFromCustomers.CashMemoNo     = "";
                    objCollectionFromCustomers.CashMemoUsesID = Helper.CashMemuUsesIdFirst;
                    objCollectionFromCustomers.RefMemoNo      = null;
                }

                objCollectionFromCustomers.CollectedByEmployee = null;
                objCollectionFromCustomers.RefAELocationCode   = objLoginHelper.LocationCode;
                objCollectionFromCustomers.UserID    = objLoginHelper.LogInID;
                objCollectionFromCustomers.EntryTime = DateTime.Now;

                salesDal.CustomerCollectionSaveForUpdateOrDelete(fCollection["hfUpdateNDeleteOptions"], objCollectionFromCustomers);
                return(new JsonResult {
                    Data = ExceptionHelper.ExceptionMessage(string.Empty)
                });
            }
            catch (Exception ex)
            {
                return(new JsonResult {
                    Data = ExceptionHelper.ExceptionMessage(ex)
                });
            }
        }
Exemplo n.º 2
0
        //public ActionResult SalesAuditAdjsutment()
        //{
        //    objLoginHelper = (LoginHelper)Session["LogInInformation"];

        //    PageAccessRightHelper objPageAccessRightHelper = new PageAccessRightHelper();
        //    objPageAccessRightHelper = securityDal.ReadPageAccessRight(Helper.ForSales, "SalesAuditAdjsutment", objLoginHelper.UerRoleOrGroupID, Helper.Inactive);
        //    if (objPageAccessRightHelper != null)
        //    {
        //        if (objPageAccessRightHelper.AccessStatus == Helper.Inactive)
        //        {
        //            Session["messageInformation"] = objPageAccessRightHelper.MessageToShow;
        //            return RedirectToAction("ErrorMessage", "../ErrorHnadle");
        //        }
        //    }

        //    ViewBag.CustomerStatus = salesDal.CustomerStatus();
        //    TempData["selectValue"] = "0";

        //    Aud_AuditingMaster objAuditMaster = new Aud_AuditingMaster();
        //    objAuditMaster = salesDal.AuditingMasterByLocationCode(objLoginHelper.LogInForUnitCode);

        //    if (objAuditMaster != null)
        //    {
        //        ViewBag.AuditStartDate = objAuditMaster.AuditStartDate != null ? Helper.DateFormat(Convert.ToDateTime(objAuditMaster.AuditStartDate)) : Helper.DateFormat(DateTime.Now);
        //        ViewBag.AuditFinishedDate = objAuditMaster.AuditFinishDate != null ? Helper.DateFormat(Convert.ToDateTime(objAuditMaster.AuditFinishDate)) : "";
        //        ViewBag.AuditCode = objAuditMaster.AuditSeqNo;
        //    }
        //    else
        //    {
        //        ViewBag.AuditStartDate = "";
        //        ViewBag.AuditFinishedDate = "";
        //        ViewBag.AuditCode = "";
        //    }

        //    if (string.IsNullOrEmpty(Request.Params["grvSalesAdjustment-page"]))
        //    {
        //        Session.Remove("CustomerType");
        //    }

        //    if (Session["CustomerType"] != null)
        //    {
        //        string ctype = Session["CustomerType"].ToString();
        //        byte customerType = Convert.ToByte(ctype);

        //        TempData["CStatus"] = salesDal.ReadCustomerListWithRecoveryStatus(objLoginHelper.LogInForUnitCode, Convert.ToByte(ctype), Helper.DateTo(objLoginHelper.AuditorYearMonth));

        //        List<Aud_AdjustmentReasonCodes> salesAuditReasons = new List<Aud_AdjustmentReasonCodes>();
        //        //salesAuditReasons = salesDal.SalesAuditResonCodes();

        //        TempData["SalesAuditReason"] = salesAuditReasons;

        //        TempData["selectValue"] = ctype;

        //        if (customerType == Helper.FullPaiedCustomer || customerType == Helper.CashSalesCustomer || customerType == Helper.SystemReturnCustomer)
        //        {
        //            TempData["DisplayOrNot"] = true;
        //        }
        //        else
        //        {
        //            TempData["DisplayOrNot"] = false;
        //        }

        //        string recoveredUpToWithoutDP = "";

        //        recoveredUpToWithoutDP = "Recovered Up to " + Helper.DateTo(objLoginHelper.AuditorYearMonth).ToString("dd-MMM-yy") + " Without DP";

        //        TempData["recoveredUpToWithoutDP"] = recoveredUpToWithoutDP;
        //    }

        //    ViewBag.LocationTitle = objLoginHelper.LocationTitle;
        //    ViewBag.Location = objLoginHelper.Location;
        //    ViewBag.ZoneTitle = objLoginHelper.ZoneTitle;
        //    ViewBag.ZoneName = objLoginHelper.LogInForZoneName;
        //    ViewBag.RegionTitle = objLoginHelper.RegionTitle;
        //    ViewBag.RegionName = objLoginHelper.LogInForRegionName;
        //    ViewBag.UnitTitle = objLoginHelper.UnitTitle;
        //    ViewBag.UnitName = objLoginHelper.LogInForUnitName;
        //    ViewBag.OpenMonthYear = "Month: " + objLoginHelper.MonthOpenForSales.ToString("MMMM-yy");
        //    ViewBag.ModuleName = objLoginHelper.ModluleTitle;
        //    ViewBag.TopMenu = objLoginHelper.TopMenu;

        //    if (objLoginHelper.UerRoleOrGroupID == UserGroup.RegionManager)
        //    {
        //        ViewBag.ShowHideMenu = true;
        //    }
        //    else
        //        ViewBag.ShowHideMenu = false;

        //    return View();
        //}

        //[HttpPost]
        //public ActionResult SalesAuditAdjsutment(FormCollection fCollection)
        //{
        //    objLoginHelper = (LoginHelper)Session["LogInInformation"];

        //    ViewBag.CustomerStatus = salesDal.CustomerStatus();
        //    TempData["selectValue"] = fCollection["ddlCustomerStatus"].ToString();

        //    TempData["CStatus"] = salesDal.ReadCustomerListWithRecoveryStatus(objLoginHelper.LogInForUnitCode, Convert.ToByte(fCollection["ddlCustomerStatus"].ToString()), Helper.DateTo(objLoginHelper.AuditorYearMonth));

        //    List<Aud_AdjustmentReasonCodes> salesAuditReasons = new List<Aud_AdjustmentReasonCodes>();
        //    // salesAuditReasons = salesDal.SalesAuditResonCodes();

        //    TempData["SalesAuditReason"] = salesAuditReasons;

        //    Aud_AuditingMaster objAuditMaster = new Aud_AuditingMaster();
        //    objAuditMaster = salesDal.AuditingMasterByLocationCode(objLoginHelper.LogInForUnitCode);

        //    if (objAuditMaster != null)
        //    {
        //        ViewBag.AuditStartDate = objAuditMaster.AuditStartDate != null ? Helper.DateFormat(Convert.ToDateTime(objAuditMaster.AuditStartDate)) : Helper.DateFormat(DateTime.Now);
        //        ViewBag.AuditFinishedDate = objAuditMaster.AuditFinishDate != null ? Helper.DateFormat(Convert.ToDateTime(objAuditMaster.AuditFinishDate)) : "";
        //        ViewBag.AuditCode = objAuditMaster.AuditSeqNo;
        //    }

        //    ViewBag.LocationTitle = objLoginHelper.LocationTitle;
        //    ViewBag.Location = objLoginHelper.Location;
        //    ViewBag.ZoneTitle = objLoginHelper.ZoneTitle;
        //    ViewBag.ZoneName = objLoginHelper.LogInForZoneName;
        //    ViewBag.RegionTitle = objLoginHelper.RegionTitle;
        //    ViewBag.RegionName = objLoginHelper.LogInForRegionName;
        //    ViewBag.UnitTitle = objLoginHelper.UnitTitle;
        //    ViewBag.UnitName = objLoginHelper.LogInForUnitName;

        //    ViewBag.ModuleName = objLoginHelper.ModluleTitle;
        //    ViewBag.TopMenu = objLoginHelper.TopMenu;

        //    Session["CustomerType"] = fCollection["ddlCustomerStatus"].ToString();
        //    byte customerType = Convert.ToByte(fCollection["ddlCustomerStatus"]);

        //    if (customerType == Helper.FullPaiedCustomer || customerType == Helper.CashSalesCustomer || customerType == Helper.SystemReturnCustomer)
        //    {
        //        TempData["DisplayOrNot"] = true;
        //    }
        //    else
        //    {
        //        TempData["DisplayOrNot"] = false;
        //    }

        //    if (objLoginHelper.UerRoleOrGroupID == UserGroup.RegionManager)
        //    {
        //        ViewBag.ShowHideMenu = true;
        //    }
        //    else
        //        ViewBag.ShowHideMenu = false;

        //    string recoveredUpToWithoutDP = "";

        //    recoveredUpToWithoutDP = "Recovered Up to " + Helper.DateTo(objLoginHelper.AuditorYearMonth).ToString("dd-MMM-yy") + " Without DP";

        //    TempData["recoveredUpToWithoutDP"] = recoveredUpToWithoutDP;

        //    return View();
        //}

        //public JsonResult SalesAuditAdjsutmentSave(string customerCode, string salesAdjustmentValue, string auditReason, string remarks)
        //{
        //    short auditSequenceNumber = 0;
        //    string saveMessage = string.Empty;

        //    //tbl_UnitWiseCustomerStatus objCustomerStatus = new tbl_UnitWiseCustomerStatus();
        //    Aud_AuditingMaster objAuditMaster = new Aud_AuditingMaster();

        //    try
        //    {
        //        objLoginHelper = (LoginHelper)Session["LogInInformation"];

        //        // objCustomerStatus = salesDal.ReadUnitWiseCustomerStatus(customerCode);
        //        objAuditMaster = salesDal.AuditingMasterByLocationCode(objLoginHelper.LogInForUnitCode);

        //        if (objAuditMaster != null)
        //        {
        //            auditSequenceNumber = Convert.ToInt16(objAuditMaster.AuditSeqNo);
        //        }
        //        else
        //        {
        //            auditSequenceNumber += 1;

        //            objAuditMaster = new Aud_AuditingMaster();

        //            objAuditMaster.LocationCode = objLoginHelper.LogInForUnitCode;
        //            //objAuditMaster.AuditForSalInvAccHrm = Helper.ForSales;
        //            objAuditMaster.AuditSeqNo = auditSequenceNumber.ToString();
        //            objAuditMaster.AuditStartDate = DateTime.Now;
        //            objAuditMaster.CreatedBy = objLoginHelper.LogInID;
        //            objAuditMaster.CreatedOn = DateTime.Now;

        //            salesDal.SaveAuditingMaster(objAuditMaster);
        //        }

        //        //if (objCustomerStatus != null)
        //        //{
        //        //    objCustomerStatus.AuditAdjustmentInSep = Convert.ToDecimal(salesAdjustmentValue);
        //        //    objCustomerStatus.RefAuditSeqNo = auditSequenceNumber;
        //        //    objCustomerStatus.Remarks = remarks;

        //        //    if (auditReason == "0")
        //        //    {
        //        //        objCustomerStatus.RefReasonForAuditAdjustment = null;
        //        //    }
        //        //    else
        //        //        objCustomerStatus.RefReasonForAuditAdjustment = auditReason;

        //        //    objCustomerStatus = salesDal.UpdateUnitWiseCustomerStatus(objCustomerStatus);

        //        //    if (objCustomerStatus != null)
        //        //    {
        //        //        saveMessage = "Save is Succeed";
        //        //    }

        //        //}
        //        //else
        //        //{ saveMessage = "Entry Is Not Valid."; }

        //    }
        //    catch (Exception ex)
        //    {
        //        saveMessage = "Save is not Succeed.";
        //    }

        //    return new JsonResult { Data = saveMessage };
        //}

        //public JsonResult FinishedAuditAdjustment()
        //{
        //    short auditSequenceNumber = 0;
        //    string updateMessage = string.Empty;
        //    Aud_AuditingMaster objAuditMaster = new Aud_AuditingMaster();

        //    objLoginHelper = (LoginHelper)Session["LogInInformation"];

        //    try
        //    {
        //        objAuditMaster = salesDal.AuditingMasterByLocationCode(objLoginHelper.LogInForUnitCode);
        //        if (objAuditMaster != null && objAuditMaster.AuditFinishDate == null)
        //        {
        //            objAuditMaster.AuditFinishDate = DateTime.Now;
        //            salesDal.UpdateAuditingMaster(objAuditMaster);

        //            if (objAuditMaster != null)
        //                updateMessage = "succeedSave";
        //            else
        //                updateMessage = "failed";
        //        }
        //        else if (objAuditMaster == null)
        //        {
        //            auditSequenceNumber += 1;

        //            objAuditMaster = new Aud_AuditingMaster();

        //            objAuditMaster.LocationCode = objLoginHelper.LogInForUnitCode;
        //            //objAuditMaster.AuditForSalInvAccHrm = Helper.ForInventory;
        //            objAuditMaster.AuditSeqNo = auditSequenceNumber.ToString();
        //            objAuditMaster.AuditStartDate = DateTime.Now;
        //            objAuditMaster.CreatedBy = objLoginHelper.LogInID;
        //            objAuditMaster.CreatedOn = DateTime.Now;

        //            salesDal.SaveAuditingMaster(objAuditMaster);

        //            if (objAuditMaster != null)
        //                updateMessage = "succeedSave";
        //            else
        //                updateMessage = "failed";
        //        }
        //        else
        //        {
        //            updateMessage = "alreadyFinished";
        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        updateMessage = "failed";
        //    }

        //    return new JsonResult { Data = updateMessage };
        //}

        public JsonResult SaveCustomerCollectionAdjustment(FormCollection fCollection)
        {
            objLoginHelper = (LoginHelper)Session["LogInInformation"];

            int    serial = 0;
            string auditSequenceNumber = string.Empty;

            Sal_CollectionFromCustomers objCustomerCollection = new Sal_CollectionFromCustomers();
            Aud_AuditAdjustmentRelatedCollectionFromCustomers objCollectionAuditAdjustnment = new Aud_AuditAdjustmentRelatedCollectionFromCustomers();

            try
            {
                if (fCollection["hfCollectionSerials"] == "0")
                {
                    serial = salesDal.CustomerCollectionSerial(fCollection["hfCustomerCodeForCollection"], Helper.ConvertDateToYearMonth(objLoginHelper.MonthOpenForSales));
                }
                else
                {
                    serial = Convert.ToInt32(fCollection["hfCollectionSerials"]);
                }

                auditSequenceNumber = hraDal.ReadAuditSeqNumberAfterCheckFinishedDate(objLoginHelper.LocationCode);

                objCustomerCollection.CustomerCode                   = fCollection["hfCustomerCodeForCollection"];
                objCustomerCollection.YearMonth                      = Helper.ConvertDateToYearMonth(objLoginHelper.MonthOpenForSales);
                objCustomerCollection.SerialNo                       = Convert.ToByte(serial);
                objCustomerCollection.CollectionType                 = Helper.CollectionTypeAAA;
                objCustomerCollection.CollectionAmount               = Convert.ToDecimal(fCollection["txtCollectionAmount"]);
                objCustomerCollection.CollectionAmount_Principal     = Convert.ToDecimal(fCollection["CollectionAmount_Principal"]);
                objCustomerCollection.CollectionAmount_ServiceCharge = Convert.ToDecimal(fCollection["CollectionAmount_ServiceCharge"]);
                objCustomerCollection.CollectionDate                 = Convert.ToDateTime(Helper.DateFormatMMDDYYYY(fCollection["dtpCollectionDate"]));

                if (!string.IsNullOrEmpty(fCollection["txtMemoNumber"]) || String.IsNullOrEmpty(fCollection["txtMemoNumber"]))
                {
                    objCustomerCollection.RefMemoNo = fCollection["txtMemoNumber"];

                    //string firstCharacterOfCashMemo = fCollection["txtMemoNumber"].Trim().Substring(0, 1);

                    //if (firstCharacterOfCashMemo.ToUpper() == "A" || !String.IsNullOrEmpty(firstCharacterOfCashMemo))
                    //{
                    string firstCharacterOfCashMemo = fCollection["txtMemoNumber"].Trim();



                    if (firstCharacterOfCashMemo.ToUpper() == "BLANK")
                    {
                        objCustomerCollection.CashMemoNo     = fCollection["txtMemoNumber"];
                        objCustomerCollection.CashMemoUsesID = "NULL";
                        objCustomerCollection.RefMemoNo      = null;
                    }
                    else
                    {
                        objCustomerCollection.CashMemoNo     = fCollection["txtMemoNumber"];
                        objCustomerCollection.CashMemoUsesID = Helper.CashMemuUsesIdFirst;
                        objCustomerCollection.RefMemoNo      = null;
                    }

                    objCustomerCollection.RefAELocationCode = objLoginHelper.LocationCode;
                    //}
                }


                objCustomerCollection.CollectedByEmployee = fCollection["hfCustomerFprPerson"].Trim();

                objCustomerCollection.UserID    = objLoginHelper.LogInID;
                objCustomerCollection.EntryTime = DateTime.Now;

                objCollectionAuditAdjustnment.CustomerCode          = fCollection["hfCustomerCodeForCollection"];
                objCollectionAuditAdjustnment.YearMonth             = Helper.ConvertDateToYearMonth(objLoginHelper.MonthOpenForSales);
                objCollectionAuditAdjustnment.SerialNo              = Convert.ToByte(serial);
                objCollectionAuditAdjustnment.AuditSeqNo            = auditSequenceNumber;
                objCollectionAuditAdjustnment.CollectionInUnit      = objLoginHelper.LocationCode;
                objCollectionAuditAdjustnment.ReasonCode            = fCollection["ddlAuditReason"].Trim();
                objCollectionAuditAdjustnment.ResponsibleEmployeeID = fCollection["hfResponsibeEmployee"].Trim();
                objCollectionAuditAdjustnment.Remarks = fCollection["txtClaimRemarks"].Trim();

                //if (fCollection["ddlAuditReason"].Trim() == "CASCOBDEPM" || fCollection["ddlAuditReason"].Trim() == "CASCONDEPM" || fCollection["ddlAuditReason"].Trim() == "CASCONDEPW")
                //{ }

                if (fCollection["hfCollectionSerials"] == "0")
                {
                    objCollectionAuditAdjustnment = salesDal.SaveCustomerCollectionForAudit(objCustomerCollection, objCollectionAuditAdjustnment, Helper.CashMemuUsesIdFirst);
                }
                else
                {
                    objCustomerCollection = salesDal.UpdateCustomerCollectionAuditAdjustment(objCustomerCollection, objCollectionAuditAdjustnment);
                }

                return(new JsonResult {
                    Data = ExceptionHelper.ExceptionMessage(string.Empty)
                });
            }
            catch (Exception ex)
            {
                return(new JsonResult {
                    Data = ExceptionHelper.ExceptionMessage(ex)
                });
            }
        }