コード例 #1
0
        //public ActionResult Search(string ps_AllLoc, string ps_Location)
        //{
        //    DALBudgetEntry objDal = new DALBudgetEntry();
        //    int li_AllLocation = -1;//, li_AllBudgetType = -1, li_AllDate = -1;
        //    try
        //    {
        //        if (ps_Location == null || ps_Location == "" || ps_Location == "0")
        //        {
        //            li_AllLocation = 1;
        //        }
        //        else
        //        {
        //            li_AllLocation = 0;
        //        }
        //        //if (ps_BudgetType == null || ps_BudgetType == "" || ps_BudgetType == "0")
        //        //{
        //        //    li_AllBudgetType = 1;
        //        //}
        //        //else
        //        //{
        //        //    li_AllBudgetType = 0;
        //        //}
        //        //if (ps_DateFrom == null || ps_DateFrom == "" || ps_DateTo == null || ps_DateTo == "")
        //        //{
        //        //    li_AllDate = 1;
        //        //}
        //        //else
        //        //{
        //        //    li_AllDate = 0;
        //        //}
        //        //objDal.GetBudgetEntryConsoleData(li_AllLocation, ps_Location, li_AllBudgetType, ps_BudgetType, li_AllDate, ps_DateFrom, ps_DateTo, false);
        //        objDal.GetBudgetEntryConsoleData(li_AllLocation, ps_Location, 1, "", 1, "", "", true);
        //        return PartialView("GridData");
        //    }
        //    catch
        //    {
        //        return PartialView("GridData");
        //    }
        //}
        public ActionResult DeleteBudget_ByBgdtMasId(String ps_BgdtMasId)
        {
            DALBudgetEntry objDal = new DALBudgetEntry();
            String[] ls_Lable = new String[7], ls_Data = new String[7];
            Int32 li_ReturnValue = 0;

            try
            {
                //GL_BgdtMaster BudgetMasterRow = objDal.GetAllMasterRecords().Where(c => c.BgdtMas_Id.Equals(ps_Id)).SingleOrDefault();
                //List<GL_VchrDetail> BudgetDetailList = objDal.GetAllDetailRecords().Where(c => c.BgdtMas_Id.Equals(ps_Id)).ToList();

                li_ReturnValue = objDal.DeleteBudgetDetail_ByBgdtMasId(ps_BgdtMasId);
                li_ReturnValue = objDal.DeleteBudgetMaster_ByBgdtMasId(ps_BgdtMasId);

                ViewData["result"] = li_ReturnValue;

                //IsAuditTrail = System.Configuration.ConfigurationManager.AppSettings.GetValues("IsAuditTrail")[0];

                //// Delete Audit Log
                //if (li_ReturnValue > 0 && IsAuditTrail == "1")
                //{
                //    DALAuditLog objAuditLog = new DALAuditLog();

                //    ls_UserId = ((SECURITY_User)Session["user"]).User_Id;
                //    ls_Lable[0] = "Code";
                //    ls_Lable[1] = "Date";
                //    ls_Lable[2] = "Location";
                //    ls_Lable[3] = "Budget Type";
                //    ls_Lable[4] = "Remarks";
                //    ls_Lable[5] = "Status";
                //    ls_Lable[6] = "Entered By";

                //    ls_Data[0] = BudgetMasterRow.BgdtMas_Code;
                //    ls_Data[1] = Convert.ToString(BudgetMasterRow.BgdtMas_Date);
                //    ls_Data[2] = BudgetMasterRow.Loc_Id;
                //    ls_Data[3] = BudgetMasterRow.VchrType_Id;
                //    ls_Data[4] = BudgetMasterRow.BgdtMas_Remarks;
                //    ls_Data[5] = BudgetMasterRow.BgdtMas_Status;
                //    ls_Data[6] = BudgetMasterRow.BgdtMas_EnteredBy;

                //    objAuditLog.SaveRecord(16, ls_UserId, ls_Action, ls_Lable, ls_Data);
                //}
                //// Audit Trail Section End
                ViewData["ddl_Location"] = new SelectList(new DALLocation().PopulateData(), "Loc_Id", "Loc_Title");
                //ViewData["ddl_BudgetType"] = new SelectList(new DALBudgetType().PopulateData(), "VchrType_Id", "VchrType_Title");
                ViewData["AllLoc"] = 1;
                ViewData["LocationId"] = "";
                //ViewData["AllVchrType"] = 1;
                //ViewData["BudgetTypeId"] = "";

                return PartialView("GridData");
            }
            catch
            {
                return PartialView("GridData");
            }
        }
コード例 #2
0
ファイル: BudgetController-Back.cs プロジェクト: khwwas/SCMS
 public void EditBudget(String BudgetId)
 {
     var BudgetEntryRow = new DALBudgetEntry().GetAllMasterRecords().Where(c => c.BgdtMas_Id.Equals(BudgetId)).SingleOrDefault();
     if (BudgetEntryRow != null)
     {
         ViewData["BudgetCode"] = BudgetEntryRow.BgdtMas_Code;
         ViewData["BudgetId"] = BudgetEntryRow.BgdtMas_Id;
         ViewData["CurrentDate"] = Convert.ToDateTime(BudgetEntryRow.BgdtMas_Date).ToString("MM/dd/yyyy");
         ViewData["Status"] = BudgetEntryRow.BgdtMas_Status;
         ViewData["BudgetType"] = BudgetEntryRow.BgdtType_Id;
         ViewData["LocationId"] = BudgetEntryRow.Loc_Id;
         ViewData["Remarks"] = BudgetEntryRow.BgdtMas_Remarks;
         //var BudgetDetailRows = new DALBudgetEntry().GetAllDetailRecords().Where(c => c.BgdtMas_Id.Equals(BudgetId)).ToList().OrderBy(c => c.VchDet_Id).ToList();
         //ViewData["DetailRecords"] = BudgetDetailRows;
         ViewData["Edit"] = "OK";
     }
 }
コード例 #3
0
        public ActionResult CancelBudget_ByBgdtMasId(String ps_BgdtMasId)
        {
            DALBudgetEntry objDal = new DALBudgetEntry();
            String[] ls_Lable = new String[7], ls_Data = new String[7];
            Int32 li_ReturnValue = 0;

            try
            {
                li_ReturnValue = objDal.CancelBudget_ByBgdtMasId(ps_BgdtMasId);
                ViewData["result"] = li_ReturnValue;
                ViewData["ddl_Location"] = new SelectList(new DALLocation().PopulateData(), "Loc_Id", "Loc_Title");
                ViewData["AllLoc"] = 1;
                ViewData["LocationId"] = "";

                return PartialView("GridData");
            }
            catch
            {
                return PartialView("GridData");
            }
        }
コード例 #4
0
ファイル: BudgetController-Back.cs プロジェクト: khwwas/SCMS
        //public String GetLastRecordByBudgetTypeId(string LocationId, string BudgetTypeId)
        //{
        //    var Budget = new DALBudgetEntry().GetLastRecordByVchrType(LocationId, BudgetTypeId);
        //    String LastBudget = "";
        //    if (Budget != null && Budget.Count > 0)
        //    {
        //        LastBudget += "<div class='CustomCell' style='width: 800px; height: 30px; font-family: Tahoma;'>";
        //        LastBudget += "<b>Budget # : </b>";
        //        LastBudget += Budget.Last().BgdtMas_Code;
        //        LastBudget += "<b>, Date : </b>";
        //        LastBudget += Budget.Last().BgdtMas_Date != null ? Convert.ToDateTime(Budget.Last().BgdtMas_Date).ToShortDateString() : "";
        //        LastBudget += "<b>, Status : </b>";
        //        LastBudget += Budget.Last().BgdtMas_Status;
        //        LastBudget += "</div>";
        //        LastBudget += "<div class='Clear' style='border-bottom: 1px solid #ccc; margin-bottom: 5px;'>";
        //        LastBudget += "</div>";
        //    }
        //    return LastBudget;
        //}
        //public ActionResult SaveBudget(String BudgetMasterCode, DateTime BudgetDate, string Status, String BudgetType, String LocationId, String Remarks, String[] BudgetDetailRows)
        //[HttpPost]
        //[AcceptVerbs(HttpVerbs.Post)]
        public string SaveBudget(IEnumerable<string> BudgetRow)
        {
            //Session["BudgetTypeForBudgetEntry"] = BudgetType;
            //Session["LocationIdForBudgetEntry"] = LocationId;
            DALBudgetEntry objDalBudgetEntry = new DALBudgetEntry();
            DALCalendar objDalCalendar = new DALCalendar();
            GL_BgdtMaster GLBgdtMaster = new GL_BgdtMaster();
            //int flag = 0;

            //String ls_Action = "Edit", IsAuditTrail = "", ls_UserId = "";
            //String[] ls_Lable = new String[7], ls_Data = new String[7];
            Int32 li_ReturnValue = 0;

            try
            {

                //    GL_VchrDetail GL_Detail = new GL_VchrDetail();
                //    String Prefix = new DALBudgetType().GetAllData().Where(c => c.BgdtType_Id.Equals(BudgetType)).SingleOrDefault().VchrType_Prefix;
                //    ls_VchrTypId = Convert.ToString(Convert.ToInt32(BudgetType));

                String[] MasterRow = BudgetRow.Last().Split('║');
                String BudgetMasterId = MasterRow[0];
                String BudgetMasterCode = MasterRow[1].Replace("[Auto]", null);
                DateTime BudgetDate = MasterRow[2] != null ? Convert.ToDateTime(MasterRow[2]) : DateTime.Now;
                String Status = MasterRow[3];
                String BudgetType = MasterRow[4];
                String Year = MasterRow[5];
                String LocationId = MasterRow[6];
                String Remarks = MasterRow[7];
                string ls_YearPrefix = "";

                //if (String.IsNullOrEmpty(BudgetMasterId))
                if (String.IsNullOrEmpty(BudgetMasterCode))
                {
                    if (DALCommon.AutoCodeGeneration("GL_BgdtMaster") == 1)
                    {
                        ls_YearPrefix = objDalCalendar.GetCalendarPrefix_ByCurrentDate(BudgetDate);
                        if (ls_YearPrefix == null && ls_YearPrefix == "")
                        {
                            return "";
                        }
                        BudgetMasterId = DALCommon.GetMaxBudgetMasId(ls_YearPrefix);
                        BudgetMasterCode = BudgetMasterId;
                        //BudgetMasterCode = DALCommon.GetMaxBudgetCode("GL_VchrMaster", BudgetType, Prefix, LocationId, ls_YearPrefix);
                        //ls_Action = "Add";
                    }
                }

                //    List<GL_VchrDetail> BudgetDetailList = new List<GL_VchrDetail>();

                if (!String.IsNullOrEmpty(BudgetMasterCode))
                {
                    //ViewData["BudgetId"] = BudgetMasterId;
                    //ViewData["BudgetCode"] = BudgetMasterCode;

                    GLBgdtMaster.BgdtMas_Id = BudgetMasterId;
                    GLBgdtMaster.BgdtMas_Code = BudgetMasterCode;
                    GLBgdtMaster.BgdtMas_Date = BudgetDate;
                    GLBgdtMaster.BgdtMas_Status = Status;
                    GLBgdtMaster.BgdtType_Id = BudgetType;
                    GLBgdtMaster.Cldr_Id = Year;
                    GLBgdtMaster.Loc_Id = LocationId;
                    GLBgdtMaster.BgdtMas_Remarks = Remarks;
                    GLBgdtMaster.BgdtMas_EnteredDate = DateTime.Now;
                    GLBgdtMaster.BgdtMas_EnteredBy = ((SECURITY_User)Session["user"]).User_Title;
                    li_ReturnValue = objDalBudgetEntry.SaveBudgetMaster(GLBgdtMaster);
                    //        if (li_ReturnValue > 0)
                    //        {
                    //            if (flag == 1)
                    //            {
                    //                objDalBudgetEntry.DeleteDetailRecordByMasterId(BudgetMasterId);
                    //            }
                    //            for (int index = 0; index < BudgetDetailRows.ToList().Count - 1; index++)
                    //            {
                    //                string Row = BudgetDetailRows.ToList()[index];
                    //                String[] Columns = Row.Split('║');
                    //                String BudgetDetailCode = "";

                    //                if (String.IsNullOrEmpty(BudgetDetailCode))
                    //                {
                    //                    if (DALCommon.AutoCodeGeneration("GL_VchrDetail") == 1)
                    //                    {
                    //                        BudgetDetailCode = DALCommon.GetMaximumCode("GL_VchrDetail");
                    //                        //BudgetDetailCode = BudgetMasterCode;
                    //                    }
                    //                }

                    //                if (!String.IsNullOrEmpty(BudgetDetailCode) && Columns[0] != null && Columns[0] != "" && Columns[0] != "0" && ((Columns[1] != null && Columns[1] != "") || (Columns[2] != null && Columns[2] != "")))
                    //                {
                    //                    GL_Detail = new GL_VchrDetail();
                    //                    GL_Detail.VchDet_Id = BudgetDetailCode;
                    //                    GL_Detail.BgdtMas_Id = BudgetMasterId;
                    //                    GL_Detail.ChrtAcc_Id = Columns[0].ToString(); //Columns[0] has AccountId from Account Title drop down;
                    //                    GL_Detail.VchMas_DrAmount = (Columns[1] != null && Columns[1] != "") ? Convert.ToDecimal(Columns[1].Replace(",", "")) : 0; // Columns[1] has Debit Amount
                    //                    GL_Detail.VchMas_CrAmount = (Columns[2] != null && Columns[2] != "") ? Convert.ToDecimal(Columns[2].Replace(",", "")) : 0; // Columns[2] has Debit Amount
                    //                    GL_Detail.VchDet_Remarks = (Columns[3] != null && Columns[3] != "") ? Columns[3].ToString() : ""; // Columns[3] has Remarks
                    //                    objDalBudgetEntry.SaveBudgetDetail(GL_Detail);
                    //                    BudgetDetailList.Add(GL_Detail);
                    //                }
                    //            }
                    //        }
                }
                //ViewData["SaveResult"] = li_ReturnValue;

                //    IsAuditTrail = System.Configuration.ConfigurationManager.AppSettings.GetValues("IsAuditTrail")[0];

                //    // Save Audit Log
                //    if (li_ReturnValue > 0 && IsAuditTrail == "1")
                //    {
                //        DALAuditLog objAuditLog = new DALAuditLog();

                //        ls_UserId = ((SECURITY_User)Session["user"]).User_Id;
                //        ls_Lable[0] = "Code";
                //        ls_Lable[1] = "Date";
                //        ls_Lable[2] = "Location";
                //        ls_Lable[3] = "Budget Type";
                //        ls_Lable[4] = "Remarks";
                //        ls_Lable[5] = "Status";

                //        ls_Data[0] = BudgetMasterCode;
                //        ls_Data[1] = BudgetDate.ToString("dd/MM/yyyy");
                //        ls_Data[2] = LocationId;
                //        ls_Data[3] = BudgetType;
                //        ls_Data[4] = Remarks;
                //        ls_Data[5] = Status;

                //        foreach (GL_VchrDetail BudgetDetail in BudgetDetailList)
                //        {
                //            Increment++;
                //            ls_Lable[Increment] = "Account Code";
                //            ls_Data[Increment] = BudgetDetail.ChrtAcc_Id;

                //            Increment++;
                //            ls_Lable[Increment] = "Debit";
                //            ls_Data[Increment] = Convert.ToString(BudgetDetail.VchMas_DrAmount);

                //            Increment++;
                //            ls_Lable[Increment] = "Credit";
                //            ls_Data[Increment] = Convert.ToString(BudgetDetail.VchMas_CrAmount);

                //            Increment++;
                //            ls_Lable[Increment] = "Narration";
                //            ls_Data[Increment] = BudgetDetail.VchDet_Remarks;
                //        }

                //        objAuditLog.SaveRecord(7, ls_UserId, ls_Action, ls_Lable, ls_Data);
                //    }
                //    //// Audit Trail Entry Section
                //    //if (li_ReturnValue > 0)
                //    //{
                //    //    string IsAuditTrail = System.Configuration.ConfigurationManager.AppSettings.GetValues(3)[0];
                //    //    if (IsAuditTrail == "1")
                //    //    {
                //    //        SYSTEM_AuditTrail systemAuditTrail = new SYSTEM_AuditTrail();
                //    //        DALAuditLog objAuditTrail = new DALAuditLog();
                //    //        systemAuditTrail.Scr_Id = flag == 0 ? 17 : 16;
                //    //        systemAuditTrail.User_Id = ((SECURITY_User)Session["user"]).User_Id;
                //    //        systemAuditTrail.Loc_Id = GL_Master.Loc_Id;
                //    //        systemAuditTrail.BgdtType_Id = GL_Master.BgdtType_Id;
                //    //        systemAuditTrail.AdtTrl_Action = flag == 0 ? "Add" : "Edit";
                //    //        systemAuditTrail.AdtTrl_EntryId = BudgetMasterId;
                //    //        systemAuditTrail.AdtTrl_DataDump = "BgdtMas_Id = " + GL_Master.BgdtMas_Id + ";";
                //    //        systemAuditTrail.AdtTrl_DataDump += "BgdtMas_Code = " + GL_Master.BgdtMas_Code + ";";
                //    //        systemAuditTrail.AdtTrl_DataDump += "BgdtMas_Date = " + GL_Master.BgdtMas_Date + ";";
                //    //        systemAuditTrail.AdtTrl_DataDump += "Cmp_Id = " + GL_Master.Cmp_Id + ";";
                //    //        systemAuditTrail.AdtTrl_DataDump += "Loc_Id = " + GL_Master.Loc_Id + ";";
                //    //        systemAuditTrail.AdtTrl_DataDump += "BgdtType_Id = " + GL_Master.BgdtType_Id + ";";
                //    //        systemAuditTrail.AdtTrl_DataDump += "BgdtMas_Remarks = " + GL_Master.BgdtMas_Remarks + ";";
                //    //        systemAuditTrail.AdtTrl_DataDump += "BgdtMas_Status = " + GL_Master.BgdtMas_Status + ";";
                //    //        systemAuditTrail.AdtTrl_DataDump += "VchMas_EnteredBy = " + GL_Master.VchMas_EnteredBy + ";";
                //    //        systemAuditTrail.AdtTrl_DataDump += "VchMas_EnteredDate = " + GL_Master.VchMas_EnteredDate + ";";
                //    //        systemAuditTrail.AdtTrl_DataDump += "VchMas_ApprovedBy = " + GL_Master.VchMas_ApprovedBy + ";";
                //    //        systemAuditTrail.AdtTrl_DataDump += "VchMas_ApprovedDate = " + GL_Master.VchMas_ApprovedDate + ";";
                //    //        systemAuditTrail.AdtTrl_DataDump += "SyncStatus = " + GL_Master.SyncStatus + ";";

                //    //        foreach (GL_VchrDetail BudgetDetail in BudgetDetailList)
                //    //        {
                //    //            systemAuditTrail.AdtTrl_DataDump += "║ VchDet_Id = " + BudgetDetail.VchDet_Id + ";";
                //    //            systemAuditTrail.AdtTrl_DataDump += "BgdtMas_Id = " + BudgetDetail.BgdtMas_Id + ";";
                //    //            systemAuditTrail.AdtTrl_DataDump += "ChrtAcc_Id = " + BudgetDetail.ChrtAcc_Id + ";";
                //    //            systemAuditTrail.AdtTrl_DataDump += "VchMas_DrAmount = " + BudgetDetail.VchMas_DrAmount + ";";
                //    //            systemAuditTrail.AdtTrl_DataDump += "VchMas_CrAmount = " + BudgetDetail.VchMas_CrAmount + ";";
                //    //            systemAuditTrail.AdtTrl_DataDump += "VchDet_Remarks = " + BudgetDetail.VchDet_Remarks + ";";
                //    //        }

                //    //        systemAuditTrail.AdtTrl_Date = DateTime.Now;
                //    //        objAuditTrail.SaveRecord(systemAuditTrail);
                //    //    }
                //    //}
                //    //// Audit Trail Section End

                //    //return PartialView("GridData");
                //    //string result = ViewData["BudgetId"].ToString(); //+ "|" + ViewData["BudgetCode"].ToString() + "|" + ViewData["SaveResult"].ToString();
                string[] rList = new string[3];
                rList[0] = BudgetMasterId;// ViewData["BudgetId"].ToString();
                rList[1] = BudgetMasterCode;// ViewData["BudgetCode"].ToString();
                rList[2] = li_ReturnValue.ToString();// ViewData["SaveResult"].ToString();
                System.Web.Script.Serialization.JavaScriptSerializer se = new System.Web.Script.Serialization.JavaScriptSerializer();
                string result = se.Serialize(rList);
                return result;
            }
            catch
            {
                ViewData["SaveResult"] = 0;
                //return PartialView("GridData");
                return "0";
            }

            //return li_ReturnValue.ToString();
        }
コード例 #5
0
ファイル: BudgetController.cs プロジェクト: khwwas/SCMS
        public ActionResult Temp_CopyBudget(FormCollection frm)
        {
            DALBudgetEntry dal_BudgetEntry = new DALBudgetEntry();
            DALCalendar dal_Calendar = new DALCalendar();
            GL_BgdtMaster ds_ExistingBudgetMaster;
            Int64 li_BudgetTotalAmount = 0;
            string ls_YearPrefix = "", ls_NewMasterId = "", ls_CurrentMasterId = "", ls_ApplicableOn = "", ls_InflateDeflate = "";
            Int64 li_ApplicablePercent = 0;

            try
            {
                ls_CurrentMasterId = frm["MasterId"];
                ls_ApplicableOn = frm["rdo_BudgetActual"];
                li_ApplicablePercent = Convert.ToInt32(frm["percentage"]);
                ls_InflateDeflate = frm["rdo_InflateDeflate"];

                if (DALCommon.AutoCodeGeneration("GL_BgdtMaster") == 1)
                {
                    ls_YearPrefix = dal_Calendar.GetCalendarPrefix_ByCurrentDate(DateTime.Now);
                    ls_NewMasterId = DALCommon.GetMaxBudgetMasId(ls_YearPrefix);
                }

                ds_ExistingBudgetMaster = dal_BudgetEntry.GetAllMasterRecords().Where(c => c.BgdtMas_Id.Equals(ls_CurrentMasterId)).SingleOrDefault();
                List<GL_BgdtDetail> SelectedBudgetDetail = new DALBudgetEntry().GetAllDetailRecords().Where(c => c.BgdtMas_Id.Equals(ls_CurrentMasterId)).ToList();
                System.Data.DataSet dsBudget = new DALReports().BudgetSummary(ds_ExistingBudgetMaster.Loc_Id, 0, ds_ExistingBudgetMaster.Cldr_Id);

                if (ls_ApplicableOn == "Budget")
                {
                    li_BudgetTotalAmount = 5000;//dsBudget.Tables[0].Rows[0]["ActualBudget"] == null ? 0 : Convert.ToInt32(dsBudget.Tables[0].Rows[0]["ActualBudget"]);//Convert.ToInt32(SelectedBudgetDetail.Sum(c => c.BgdtDet_TotalAmount));
                }
                else
                {

                    li_BudgetTotalAmount = 7000;//dsBudget.Tables[0].Rows[0]["ActualExpense"] == null ? 0 : Convert.ToInt32(dsBudget.Tables[0].Rows[0]["ActualExpense"]);
                }

                if (ls_InflateDeflate == "Inflate")
                {
                    li_BudgetTotalAmount = li_BudgetTotalAmount + ((li_BudgetTotalAmount * li_ApplicablePercent) / 100);
                }
                else
                {
                    li_BudgetTotalAmount = li_BudgetTotalAmount - ((li_BudgetTotalAmount * li_ApplicablePercent) / 100);
                }

                int BudgetPerMonth = Convert.ToInt32(li_BudgetTotalAmount / 12);

                GL_BgdtMaster NewBudgetMaster = new GL_BgdtMaster();

                NewBudgetMaster.BgdtMas_Id = ls_NewMasterId;
                NewBudgetMaster.BgdtMas_Code = ls_NewMasterId;
                NewBudgetMaster.BgdtMas_Date = DateTime.Now;
                NewBudgetMaster.BgdtMas_Status = "Pending";
                NewBudgetMaster.BgdtType_Id = ds_ExistingBudgetMaster.BgdtType_Id;
                NewBudgetMaster.Cldr_Id = ds_ExistingBudgetMaster.Cldr_Id;
                NewBudgetMaster.Loc_Id = ds_ExistingBudgetMaster.Loc_Id;
                NewBudgetMaster.BgdtMas_Remarks = "Copy of " + ds_ExistingBudgetMaster.BgdtMas_Code + " - " + ds_ExistingBudgetMaster.BgdtMas_Remarks;
                NewBudgetMaster.BgdtMas_EnteredDate = DateTime.Now;
                NewBudgetMaster.BgdtMas_EnteredBy = ((SECURITY_User)Session["user"]).User_Title;
                Int32 li_ReturnValue = dal_BudgetEntry.SaveBudgetMaster(NewBudgetMaster);

                if (li_ReturnValue > 0)
                {
                    foreach (GL_BgdtDetail detail in SelectedBudgetDetail)
                    {
                        String BudgetDetailCode = "";

                        if (String.IsNullOrEmpty(BudgetDetailCode))
                        {
                            if (DALCommon.AutoCodeGeneration("GL_BgdtDetail") == 1)
                            {
                                BudgetDetailCode = DALCommon.GetMaximumCode("GL_BgdtDetail");
                            }
                        }

                        GL_BgdtDetail dbDetail = new GL_BgdtDetail();
                        dbDetail.BgdtDet_Id = BudgetDetailCode;
                        dbDetail.BgdtMas_Id = ls_NewMasterId;
                        dbDetail.BgdtDet_Month1 = BudgetPerMonth;
                        dbDetail.BgdtDet_Month2 = BudgetPerMonth;
                        dbDetail.BgdtDet_Month3 = BudgetPerMonth;
                        dbDetail.BgdtDet_Month4 = BudgetPerMonth;
                        dbDetail.BgdtDet_Month5 = BudgetPerMonth;
                        dbDetail.BgdtDet_Month6 = BudgetPerMonth;
                        dbDetail.BgdtDet_Month7 = BudgetPerMonth;
                        dbDetail.BgdtDet_Month8 = BudgetPerMonth;
                        dbDetail.BgdtDet_Month9 = BudgetPerMonth;
                        dbDetail.BgdtDet_Month10 = BudgetPerMonth;
                        dbDetail.BgdtDet_Month11 = BudgetPerMonth;
                        dbDetail.BgdtDet_Month12 = BudgetPerMonth;
                        dbDetail.BgdtDet_TotalAmount = li_BudgetTotalAmount;
                        dbDetail.BgdtDet_Remarks = detail.BgdtDet_Remarks;
                        dbDetail.ChrtAcc_Id = detail.ChrtAcc_Id;
                        dal_BudgetEntry.SaveBudgetDetail(dbDetail);
                    }
                }

                return RedirectToAction("Index", "BudgetConsole", new { });
            }
            catch (Exception ex)
            {
                return null;
            }
        }
コード例 #6
0
ファイル: BudgetController.cs プロジェクト: khwwas/SCMS
        public string SaveBudget(SCMS.Models.BudgetMaster BudgetModel)
        {
            DALBudgetEntry objDalBudgetEntry = new DALBudgetEntry();
            DALCalendar objDalCalendar = new DALCalendar();
            GL_BgdtMaster GLBgdtMaster = new GL_BgdtMaster();
            string ls_YearPrefix = "";
            Int32 li_ReturnValue = 0;
            String ls_BudgetMasterId = "", ls_BudgetMasterCode = "", ls_Status = "", ls_BudgetType = "", ls_Year = "", ls_LocationId = "", ls_Remarks = "",
                   ls_BudgetDetailId = "";
            DateTime ldt_BudgetDate;

            try
            {
                ls_BudgetMasterId = BudgetModel.MasterId;
                ls_BudgetMasterCode = BudgetModel.Code.Replace("[Auto]", null);
                ldt_BudgetDate = !String.IsNullOrEmpty(BudgetModel.Date) ? Convert.ToDateTime(BudgetModel.Date) : DateTime.Now;
                ls_Status = BudgetModel.Status;
                ls_BudgetType = BudgetModel.BudgetType;
                ls_Year = BudgetModel.CalendarYear;
                ls_LocationId = BudgetModel.Location;
                ls_Remarks = BudgetModel.Remarks;

                //ls_YearPrefix = objDalCalendar.GetCalendarPrefix_ByCurrentDate(ldt_BudgetDate);
                ls_YearPrefix = objDalCalendar.GetCalendarPrefix_ByCldrId(ls_Year);

                if (String.IsNullOrEmpty(ls_BudgetMasterId))
                {
                    if (DALCommon.AutoCodeGeneration("GL_BgdtMaster") == 1)
                    {

                        if (ls_YearPrefix == null && ls_YearPrefix == "")
                        {
                            return "";
                        }
                        ls_BudgetMasterId = DALCommon.GetMaxBudgetMasId(ls_YearPrefix);
                        ls_BudgetMasterCode = ls_BudgetMasterId;
                    }
                }
                else
                {
                    objDalBudgetEntry.DeleteBudgetDetail_ByBgdtMasId(ls_BudgetMasterId);
                }

                if (!String.IsNullOrEmpty(ls_BudgetMasterCode))
                {
                    GLBgdtMaster.BgdtMas_Id = ls_BudgetMasterId;
                    GLBgdtMaster.BgdtMas_Code = ls_BudgetMasterCode;
                    GLBgdtMaster.BgdtMas_Date = ldt_BudgetDate;
                    GLBgdtMaster.BgdtMas_Status = ls_Status;
                    GLBgdtMaster.BgdtType_Id = ls_BudgetType;
                    GLBgdtMaster.Cldr_Id = ls_Year;
                    GLBgdtMaster.Loc_Id = ls_LocationId;
                    GLBgdtMaster.BgdtMas_Remarks = ls_Remarks;
                    GLBgdtMaster.BgdtMas_EnteredDate = DateTime.Now;
                    GLBgdtMaster.BgdtMas_EnteredBy = ((SECURITY_User)Session["user"]).User_Title;

                    li_ReturnValue = objDalBudgetEntry.SaveBudgetMaster(GLBgdtMaster);

                    if (li_ReturnValue > 0)
                    {
                        foreach (SCMS.Models.BudgetDetail detail in BudgetModel.ListBudgetDetail)
                        {
                            ls_BudgetDetailId = DALCommon.GetMaxBudgetDetId(ls_YearPrefix);

                            GL_BgdtDetail dbDetail = new GL_BgdtDetail();
                            dbDetail.BgdtDet_Id = ls_BudgetDetailId;
                            dbDetail.BgdtMas_Id = ls_BudgetMasterId;
                            dbDetail.ChrtAcc_Id = detail.Account;
                            dbDetail.BgdtDet_Month1 = detail.Month1;
                            dbDetail.BgdtDet_Month2 = detail.Month2;
                            dbDetail.BgdtDet_Month3 = detail.Month3;
                            dbDetail.BgdtDet_Month4 = detail.Month4;
                            dbDetail.BgdtDet_Month5 = detail.Month5;
                            dbDetail.BgdtDet_Month6 = detail.Month6;
                            dbDetail.BgdtDet_Month7 = detail.Month7;
                            dbDetail.BgdtDet_Month8 = detail.Month8;
                            dbDetail.BgdtDet_Month9 = detail.Month9;
                            dbDetail.BgdtDet_Month10 = detail.Month10;
                            dbDetail.BgdtDet_Month11 = detail.Month11;
                            dbDetail.BgdtDet_Month12 = detail.Month12;
                            dbDetail.BgdtDet_TotalAmount = detail.TotalAmount;
                            dbDetail.BgdtDet_Remarks = detail.Remarks;

                            objDalBudgetEntry.SaveBudgetDetail(dbDetail);
                        }
                    }
                }

                return ls_BudgetMasterId + ":" + ls_BudgetMasterCode;
            }
            catch
            {
                return "0";
            }
        }
コード例 #7
0
ファイル: BudgetController.cs プロジェクト: khwwas/SCMS
        public ActionResult CopyBudget(FormCollection frm)
        {
            DALBudgetEntry dal_BudgetEntry = new DALBudgetEntry();
            DALCalendar dal_Calendar = new DALCalendar();
            GL_BgdtMaster lst_ExistingBudgetMaster = new GL_BgdtMaster();
            GL_BgdtMaster lst_NewBudgetMaster = new GL_BgdtMaster();

            string ls_YearPrefix = "", ls_NewMasterId = "", ls_CurrentMasterId = "", ls_NewDetailId = "", ls_ApplicableOn = "", ls_InflateDeflate = "";
            Int64 li_ReturnValue = 0, li_ApplicablePercent = 0;
            decimal ldec_BudgetTotalAmount = 0, ldec_BudgetMonthlyAmount = 0;

            try
            {
                ls_CurrentMasterId = frm["MasterId"];
                ls_ApplicableOn = frm["rdo_BudgetActual"];
                li_ApplicablePercent = Convert.ToInt32(frm["percentage"]);
                ls_InflateDeflate = frm["rdo_InflateDeflate"];

                // Getting year prefix
                ls_YearPrefix = dal_Calendar.GetCalendarPrefix_ByCurrentDate(DateTime.Now);
                if (DALCommon.AutoCodeGeneration("GL_BgdtMaster") == 1)
                {
                    ls_NewMasterId = DALCommon.GetMaxBudgetMasId(ls_YearPrefix);
                }

                // Retrieving existing master and detail records
                lst_ExistingBudgetMaster = dal_BudgetEntry.GetAllMasterRecords().Where(c => c.BgdtMas_Id.Equals(ls_CurrentMasterId)).SingleOrDefault();
                List<GL_BgdtDetail> lst_ExistingBudgetDetail = dal_BudgetEntry.GetAllDetailRecords().Where(c => c.BgdtMas_Id.Equals(ls_CurrentMasterId)).ToList();

                // Setting and saving of new budget master record
                lst_NewBudgetMaster.BgdtMas_Id = ls_NewMasterId;
                lst_NewBudgetMaster.BgdtMas_Code = ls_NewMasterId;
                lst_NewBudgetMaster.BgdtMas_Date = DateTime.Now;
                lst_NewBudgetMaster.BgdtMas_Status = "Pending";
                lst_NewBudgetMaster.BgdtType_Id = lst_ExistingBudgetMaster.BgdtType_Id;
                lst_NewBudgetMaster.Cldr_Id = lst_ExistingBudgetMaster.Cldr_Id;
                lst_NewBudgetMaster.Loc_Id = lst_ExistingBudgetMaster.Loc_Id;
                lst_NewBudgetMaster.BgdtMas_Remarks = "Copy of " + lst_ExistingBudgetMaster.BgdtMas_Code + " - " + lst_ExistingBudgetMaster.BgdtMas_Remarks;
                lst_NewBudgetMaster.BgdtMas_EnteredDate = DateTime.Now;
                lst_NewBudgetMaster.BgdtMas_EnteredBy = ((SECURITY_User)Session["user"]).User_Title;

                li_ReturnValue = dal_BudgetEntry.SaveBudgetMaster(lst_NewBudgetMaster);

                if (li_ReturnValue > 0)
                {
                    foreach (GL_BgdtDetail detail in lst_ExistingBudgetDetail)
                    {
                        GL_BgdtDetail lst_NewBudgetDetail = new GL_BgdtDetail();

                        if (DALCommon.AutoCodeGeneration("GL_BgdtDetail") == 1)
                        {
                            ls_NewDetailId = DALCommon.GetMaxBudgetDetId(ls_YearPrefix);
                        }

                        lst_NewBudgetDetail.BgdtDet_Id = ls_NewDetailId;
                        lst_NewBudgetDetail.BgdtMas_Id = ls_NewMasterId;
                        lst_NewBudgetDetail.ChrtAcc_Id = detail.ChrtAcc_Id;

                        ldec_BudgetTotalAmount = 0;
                        if (ls_ApplicableOn == "Budget")
                        {
                            ldec_BudgetTotalAmount = Convert.ToDecimal(detail.BgdtDet_TotalAmount.ToString());
                        }
                        else
                        {
                            //li_BudgetTotalAmount = 7000;
                        }

                        if (ls_InflateDeflate == "Inflate")
                        {
                            ldec_BudgetTotalAmount = ldec_BudgetTotalAmount + ((ldec_BudgetTotalAmount * li_ApplicablePercent) / 100);
                        }
                        else
                        {
                            ldec_BudgetTotalAmount = ldec_BudgetTotalAmount - ((ldec_BudgetTotalAmount * li_ApplicablePercent) / 100);
                        }

                        ldec_BudgetMonthlyAmount = 0;
                        ldec_BudgetMonthlyAmount = ldec_BudgetTotalAmount / 12;

                        lst_NewBudgetDetail.BgdtDet_TotalAmount = ldec_BudgetTotalAmount;
                        lst_NewBudgetDetail.BgdtDet_Month1 = ldec_BudgetMonthlyAmount;
                        lst_NewBudgetDetail.BgdtDet_Month2 = ldec_BudgetMonthlyAmount;
                        lst_NewBudgetDetail.BgdtDet_Month3 = ldec_BudgetMonthlyAmount;
                        lst_NewBudgetDetail.BgdtDet_Month4 = ldec_BudgetMonthlyAmount;
                        lst_NewBudgetDetail.BgdtDet_Month5 = ldec_BudgetMonthlyAmount;
                        lst_NewBudgetDetail.BgdtDet_Month6 = ldec_BudgetMonthlyAmount;
                        lst_NewBudgetDetail.BgdtDet_Month7 = ldec_BudgetMonthlyAmount;
                        lst_NewBudgetDetail.BgdtDet_Month8 = ldec_BudgetMonthlyAmount;
                        lst_NewBudgetDetail.BgdtDet_Month9 = ldec_BudgetMonthlyAmount;
                        lst_NewBudgetDetail.BgdtDet_Month10 = ldec_BudgetMonthlyAmount;
                        lst_NewBudgetDetail.BgdtDet_Month11 = ldec_BudgetMonthlyAmount;
                        lst_NewBudgetDetail.BgdtDet_Month12 = ldec_BudgetTotalAmount - (ldec_BudgetMonthlyAmount * 11);
                        lst_NewBudgetDetail.BgdtDet_Remarks = detail.BgdtDet_Remarks;

                        dal_BudgetEntry.SaveBudgetDetail(lst_NewBudgetDetail);
                    }
                }

                return RedirectToAction("Index", "BudgetConsole", new { });
            }
            catch (Exception ex)
            {
                return null;
            }
        }
コード例 #8
0
ファイル: BudgetController.cs プロジェクト: khwwas/SCMS
        public ActionResult Index(string p_BudgetId)
        {
            string ls_Nature = "'Expense', 'Assets'";
            var lst_BudgetTypes = new DALBudgetType().PopulateData();
            var lst_Years = new DALCalendar().GetAllRecords();
            var lst_Locations = new DALLocation().PopulateData();
            var ChartOfAccounts = new DALChartOfAccount().GetChartOfAccountForDropDown(0, ls_Nature);
            string ChartOfAccountCodes = "";

            foreach (SETUP_ChartOfAccount COA in ChartOfAccounts)
            {
                if (ChartOfAccountCodes.Length > 0)
                {
                    ChartOfAccountCodes += "|" + COA.ChrtAcc_Id + ":" + COA.ChrtAcc_Title;
                }
                else
                {
                    ChartOfAccountCodes += COA.ChrtAcc_Id + ":" + COA.ChrtAcc_Title;
                }
            }
            ViewData["ChartOfAccountCodesWithTitles"] = ChartOfAccountCodes;

            SCMS.Models.BudgetMaster modelBudget = new SCMS.Models.BudgetMaster();
            modelBudget.ListBudgetDetail = new List<SCMS.Models.BudgetDetail>();

            if (!string.IsNullOrEmpty(p_BudgetId))
            {
                GL_BgdtMaster budget = new SCMSDataLayer.DALBudgetEntry().GetAllMasterRecords().Where(c => c.BgdtMas_Id.Equals(p_BudgetId)).SingleOrDefault();
                modelBudget.MasterId = budget.BgdtMas_Id;
                modelBudget.Code = budget.BgdtMas_Code;
                modelBudget.Date = Convert.ToDateTime(budget.BgdtMas_Date).ToString("MM/dd/yyyy");
                modelBudget.Status = budget.BgdtMas_Status;
                modelBudget.Remarks = budget.BgdtMas_Remarks;
                modelBudget.BudgetType = budget.BgdtType_Id;
                modelBudget.Location = budget.Loc_Id;
                modelBudget.CalendarYear = budget.Cldr_Id;
                List<GL_BgdtDetail> budgetDetailList = new DALBudgetEntry().GetAllDetailRecords().Where(c => c.BgdtMas_Id.Equals(p_BudgetId)).ToList();

                foreach (GL_BgdtDetail dbBudgetDetail in budgetDetailList)
                {
                    SCMS.Models.BudgetDetail budgetDetailRow = new SCMS.Models.BudgetDetail();
                    budgetDetailRow.MasterId = dbBudgetDetail.BgdtMas_Id;
                    budgetDetailRow.DetailId = dbBudgetDetail.BgdtDet_Id;
                    budgetDetailRow.Month1 = dbBudgetDetail.BgdtDet_Month1;
                    budgetDetailRow.Month2 = dbBudgetDetail.BgdtDet_Month2;
                    budgetDetailRow.Month3 = dbBudgetDetail.BgdtDet_Month3;
                    budgetDetailRow.Month4 = dbBudgetDetail.BgdtDet_Month4;
                    budgetDetailRow.Month5 = dbBudgetDetail.BgdtDet_Month5;
                    budgetDetailRow.Month6 = dbBudgetDetail.BgdtDet_Month6;
                    budgetDetailRow.Month7 = dbBudgetDetail.BgdtDet_Month7;
                    budgetDetailRow.Month8 = dbBudgetDetail.BgdtDet_Month8;
                    budgetDetailRow.Month9 = dbBudgetDetail.BgdtDet_Month9;
                    budgetDetailRow.Month10 = dbBudgetDetail.BgdtDet_Month10;
                    budgetDetailRow.Month11 = dbBudgetDetail.BgdtDet_Month11;
                    budgetDetailRow.Month12 = dbBudgetDetail.BgdtDet_Month12;
                    budgetDetailRow.TotalAmount = dbBudgetDetail.BgdtDet_TotalAmount;
                    budgetDetailRow.Account = dbBudgetDetail.ChrtAcc_Id;

                    modelBudget.ListBudgetDetail.Add(budgetDetailRow);
                }
            }
            else
            {
                modelBudget.Date = DateTime.Now.ToString("MM/dd/yyyy");
                modelBudget.Code = "[Auto]";
                SCMS.Models.BudgetDetail detail = new SCMS.Models.BudgetDetail();
                modelBudget.ListBudgetDetail.Add(detail);
            }

            ViewData["BudgetType"] = new SelectList(lst_BudgetTypes, "BgdtType_Id", "BgdtType_Title", modelBudget.BudgetType);
            ViewData["CalendarYear"] = new SelectList(lst_Years, "Cldr_Id", "Cldr_Title", modelBudget.CalendarYear);
            ViewData["Location"] = new SelectList(lst_Locations, "Loc_Id", "Loc_Title", modelBudget.Location);
            ViewData["ddl_Account"] = ChartOfAccounts;

            return View("Budget", modelBudget);
        }