Пример #1
0
    protected void Txtdocno_TextChanged(object sender, EventArgs e)
    {
        string    DocNost = Txtdocno.Text.Trim();
        int       DocNo2  = Convert.ToInt32(DocNost);
        int       strFY2  = Convert.ToInt32(strFY);
        DataTable dt1     = new DataTable();

        dt1 = JVDetail.GetJV(DocNo2, strFY2).Tables[2];

        if (dt1.Rows.Count != 0)
        {
            //TxtCmpycode.Text = "";
            //TxtBookcode.Text = "";
            //LblBookName.Text = "";
            //Txtdocno.Text = "";
            TxtdocDate.Text    = Convert.ToString(JVDetail.GetJV(DocNo2, strFY2).Tables[0].Rows[0]["JVDocDate"]);
            LblJVMasterID.Text = Convert.ToString(JVDetail.GetJV(DocNo2, strFY2).Tables[0].Rows[0]["JVMasterID"]);

            GrdJV.DataSource = JVDetail.GetJV(DocNo2, strFY2).Tables[2];
            GrdJV.DataBind();
        }
        else
        {
            MessageBox("Invalid Document No.");
            //TxtdocDate.Text = DateTime.Now.ToString("dd/MM/yyyy");
            //GrdJV.DataSource = JVDetail.GetJV(DocNo2, strFY2).Tables[2];
            //GrdJV.DataBind();
        }
    }
Пример #2
0
    public void getdata()
    {
        sdocno = Txtdocno.Text.Trim();
        DocNo  = Convert.ToInt32(sdocno);
        //string from = txtfromDate.Text.Split('/')[2] + "/" + txtfromDate.Text.Split('/')[1] + "/" + txtfromDate.Text.Split('/')[0];
        //string To = txttoDate.Text.Split('/')[2] + "/" + txttoDate.Text.Split('/')[1] + "/" + txttoDate.Text.Split('/')[0];
        //fdate = Convert.ToDateTime(from);
        //tdate = Convert.ToDateTime(To);
        //if (fdate > tdate)
        //{
        //    MessageBox("From Date is Greater than ToDate");
        //    txtfromDate.Focus();
        //}
        //else

        DataTable dt = new DataTable();

        //dt = Books.Get_Bookwise_summary(fdate, tdate).Tables[0];
        dt = JVDetail.RepGetJV(DocNo, Convert.ToInt32(strFY)).Tables[0];
        if (dt.Rows.Count > 0)
        {
            ReportDocument CR = new ReportDocument();
            CR.Load(Server.MapPath("Report/PrintJV.rpt"));
            CrptJV.SeparatePages = false;
            CR.SetDataSource(dt);
            CrptJV.ReportSource = CR;
        }
        else
        {
            MessageBox("No Records Found");
            Txtdocno.Focus();
        }
    }
Пример #3
0
    public void SaveJVDetails()
    {
        if (Session["UserName"] != null)
        {
            try
            {
                JVDetail objjvd = new JVDetail();
                JVMID1 = LblJVMasterID.Text.Trim();
                foreach (GridViewRow Row in GrdJV.Rows)
                {
                    //objjvd.JVDetailID = Convert.ToInt32(((Label)Row.FindControl("LblJVDID")).Text.Trim());
                    //objjvd.JVMasterID = Convert.ToInt32(((Label)Row.FindControl("LblJVMID")).Text.Trim());
                    JVDID1              = ((Label)Row.FindControl("LblJVDID")).Text.Trim();
                    JVDID               = Convert.ToInt32(JVDID1);
                    objjvd.JVDetailID   = JVDID;
                    objjvd.JVMasterID   = Convert.ToInt32(JVMID1);
                    objjvd.AccountCode  = ((TextBox)Row.FindControl("txtcode")).Text.Trim();
                    objjvd.ReportCode   = ((Label)Row.FindControl("LblRcode")).Text.Trim();
                    dramt               = ((TextBox)Row.FindControl("txtDebit")).Text.Trim();
                    cramt               = ((TextBox)Row.FindControl("txtCredit")).Text.Trim();
                    objjvd.CreditAmount = Convert.ToDecimal(cramt);
                    objjvd.DebitAmount  = Convert.ToDecimal(dramt);
                    objjvd.Remarks      = ((TextBox)Row.FindControl("txtCmmt")).Text.Trim();
                    objjvd.Isactive     = true;
                    objjvd.strFY        = Convert.ToInt32(strFY);
                    if (JVDID > 0)
                    {
                        objjvd.UpdatedBy = Session["UserName"].ToString();
                    }
                    else
                    {
                        objjvd.CreatedBy = Session["UserName"].ToString();
                    }

                    objjvd.Save();
                }

                //objjvd.AccountCode  = txtAccode.Text.Trim();
                //objjvd.ReportCode   = txtreportcode.Text.Trim();

                //objjvd.CreditAmount = Convert.ToInt32(Txtcreditamt.Text.Trim());
                //objjvd.DebitAmount  = Convert.ToInt32(Txtdebitamt.Text.Trim());
                //objjvd.Remarks      = TxtComment.Text.Trim();

                //MessageBox("Record saved successfully");
            }
            catch
            {
            }
        }
    }
Пример #4
0
    protected void Txtdocno_TextChanged(object sender, EventArgs e)
    {
        txtAccode.Text    = "";
        Txtdebitamt.Text  = "";
        Txtcreditamt.Text = "";

        string DocNost = Txtdocno.Text.Trim();
        int    DocNo2  = Convert.ToInt32(DocNost);
        int    strFY2  = Convert.ToInt32(strFY);

        DataTable dt1 = new DataTable();

        dt1 = JVDetail.GetJV(DocNo2, strFY2).Tables[2];
        DataTable dt11 = new DataTable();

        dt11 = JVDetail.GetJV(DocNo2, strFY2).Tables[0];
        if (dt11.Rows.Count != 0)
        {
            if (dt1.Rows.Count != 0)
            {
                //TxtCmpycode.Text = "";
                //TxtBookcode.Text = "";
                //LblBookName.Text = "";
                //Txtdocno.Text = "";
                TxtdocDate.Text    = Convert.ToString(JVDetail.GetJV(DocNo2, strFY2).Tables[0].Rows[0]["JVDocDate"]);
                LblJVMasterID.Text = Convert.ToString(JVDetail.GetJV(DocNo2, strFY2).Tables[0].Rows[0]["JVMasterID"]);

                GrdJV.DataSource = JVDetail.GetJV(DocNo2, strFY2).Tables[2];
                GrdJV.DataBind();
                btnSave.Visible       = true;
                Session["tempJVData"] = dt1;
            }

            if (dt1.Rows.Count == 0)
            {
                TxtdocDate.Text    = Convert.ToString(JVDetail.GetJV(DocNo2, strFY2).Tables[0].Rows[0]["JVDocDate"]);
                LblJVMasterID.Text = Convert.ToString(JVDetail.GetJV(DocNo2, strFY2).Tables[0].Rows[0]["JVMasterID"]);

                GrdJV.DataBind();
                btnSave.Visible = false;
            }
        }
        else
        {
            MessageBox("Invalid Document No.");
            TxtdocDate.Text = DateTime.Now.ToString("dd/MM/yyyy");
            btnSave.Visible = false;
            //GrdJV.DataSource = JVDetail.GetJV(DocNo2, strFY2).Tables[2];
            GrdJV.DataBind();
        }
    }
Пример #5
0
    protected void GrdJV_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        DataTable dt2 = new DataTable();

        dt2 = (DataTable)Session["tempJVData"];
        JVDetail objjvd1 = new JVDetail();

        int jvdid = Convert.ToInt32(((Label)GrdJV.Rows[e.RowIndex].FindControl("LblJVDID")).Text.Trim());

        if (jvdid != 0)
        {
            objjvd1.Flag      = "JVDetail";
            objjvd1.ID        = jvdid;
            objjvd1.Isactive  = Convert.ToBoolean(false);
            objjvd1.IsDeleted = Convert.ToBoolean(true);
            objjvd1.deleteJVRec();
        }
        else
        {
        }

        //dt2.Rows[e.RowIndex].Delete();
        //GrdJV.DataSource = dt2;
        //GrdJV.DataBind();
        //Session["tempJVData"] = dt2;

        dt2.Rows[e.RowIndex].Delete();
        DataView dv = new DataView(dt2);

        dv.RowFilter     = "JVDetailID is not null";
        GrdJV.DataSource = dv;
        GrdJV.DataBind();

        Session["tempJVData"] = dv.ToTable();

        dt2 = (DataTable)Session["tempJVData"];
        if (dt2.Rows.Count == 0)
        {
            btnSave.Visible = false;
        }
    }
    public void Bind()
    {
        string    from     = txtFromDate.Text.Split('/')[1].ToString() + "/" + txtFromDate.Text.Split('/')[0].ToString() + "/" + txtFromDate.Text.Split('/')[2];
        string    to       = txtToDate.Text.Split('/')[1].ToString() + "/" + txtToDate.Text.Split('/')[0].ToString() + "/" + txtToDate.Text.Split('/')[2];
        DateTime  FromDate = Convert.ToDateTime(from);
        DateTime  ToDate   = Convert.ToDateTime(to);
        DataTable dt       = new DataTable();

        dt = JVDetail.Idv_Chetana_GetJV_Report(FromDate, ToDate).Tables[0];
        if (dt.Rows.Count != 0)
        {
            ReportDocument rd = new ReportDocument();
            rd.Load(Server.MapPath("Report/JVReportDetails.rpt"));
            rd.SetDataSource(dt);
            JVReport.ReportSource = rd;
        }
        else
        {
            MessageBox("No Record Found");
        }
    }
Пример #7
0
        public void Insert(StockItemPurchaseModel model)
        {
            EHMSEntities ent = new EHMSEntities();
            var          obj = AutoMapper.Mapper.Map <StockItemPurchaseModel, StockItemPurchase>(model);

            obj.Status      = true;
            obj.CreatedBy   = 1;
            obj.CreatedDate = DateTime.Now;
            ent.StockItemPurchases.Add(obj);
            ent.SaveChanges();

            int id = ent.StockItemPurchases.Where(x => x.ItemPurchaseId == ent.StockItemPurchases.Max(y => y.ItemPurchaseId)).SingleOrDefault().ItemPurchaseId;

            foreach (var item in model.StockItemEntryList)
            {
                StockItemPurchaseDetail PurchaseDetail = new StockItemPurchaseDetail();
                var StockItemMaster = ent.StockItemMasters.Where(x => x.StockItemEntryId == item.StockItemEntryId).SingleOrDefault();
                var purchaseorder   = (from po in ent.StockPurchaseOrders
                                       join pd in ent.StockPurchaseOrderDetails
                                       on po.PurchaseOrderId equals pd.PurchaseOrderId
                                       where po.PurchaseOrderNo == model.ItemOrderId && pd.ItemId == item.StockItemEntryId
                                       select pd).SingleOrDefault();
                PurchaseDetail.ItemPurchaseId   = id;
                PurchaseDetail.StockItemEntryId = item.StockItemEntryId;
                PurchaseDetail.StockUnitId      = ent.SetupStockItemEntries.Where(x => x.StockItemEntryId == item.StockItemEntryId).SingleOrDefault().StockUnitId;
                PurchaseDetail.Quantity         = item.Quantity;
                PurchaseDetail.Rate             = item.Rate;
                PurchaseDetail.TotalAmount      = item.Quantity * item.Rate;
                PurchaseDetail.BatchNo          = item.BatchNo;
                PurchaseDetail.ExpiryDate       = item.ExpiryDate;
                PurchaseDetail.SupplierId       = model.StockSupplierId;
                PurchaseDetail.WarrentyDate     = item.WarrentyDate;
                PurchaseDetail.ManufacturedDate = item.ManufacturedDate;


                if (item.QuotQty == item.Quantity)
                {
                    purchaseorder.Status           = false;
                    ent.Entry(purchaseorder).State = System.Data.EntityState.Modified;
                }
                //else
                //{
                //    purchaseorder.Quantity = purchaseorder.Quantity - item.Quantity;
                //}
                StockItemMaster.Quantity         = StockItemMaster.Quantity + item.Quantity;
                ent.Entry(StockItemMaster).State = System.Data.EntityState.Modified;
                ent.StockItemPurchaseDetails.Add(PurchaseDetail);
            }
            ent.SaveChanges();
            //Automatic post jv
            int    VoucherNumberInt = HospitalManagementSystem.Utility.getMaxVoucherNumber("PV", 7);
            string VoucherNumber    = "PV" + "-" + Utility.GetCurrentFiscalYearNameInBS() + "-" + VoucherNumberInt.ToString();

            var objJVMaster = new JVMaster()
            {
                AccountNumber   = "1",
                BillNumber      = "123",
                VerifiedBy      = 45,
                TransactionDate = DateTime.Today,
                TotalAmount     = model.TotalAmount,
                Status          = false,
                Narration1      = "From Stock",
                Narration2      = "From Stock",
                JvType          = "PV",
                CreatedBy       = HospitalManagementSystem.Utility.GetCurrentLoginUserId(),
                CreatedDate     = DateTime.Today,
                FiscalYearId    = HospitalManagementSystem.Utility.GetCurrentFiscalYearID(),
                JvNumber        = VoucherNumber,
                FormName        = "Stock"
            };

            ent.JVMasters.Add(objJVMaster);
            ent.SaveChanges();

            int PaymentMode = model.PaymentType;//Cash or bank, credit (paryt name)
            //Dr Amount
            string AccountHeadName      = "";
            string AccountHeadNameParty = "";
            int    FeeTypeIdInt         = Convert.ToInt32(0);
            int    FeeTypeSubIDInt      = Convert.ToInt32(0);



            if (PaymentMode == 372)//credit
            {
                AccountHeadNameParty = HospitalManagementSystem.Utility.GetFeeTypeNameFromId(1831) + "-" + HospitalManagementSystem.Utility.GetFeeTypeNameFromId(1832);
                AccountHeadName      = HospitalManagementSystem.Utility.GetFeeTypeNameFromId(1833);
                FeeTypeIdInt         = 1831;
                FeeTypeSubIDInt      = 1832;
            }
            else if (PaymentMode == 373)//cash
            {
                AccountHeadNameParty = "CASH";
                AccountHeadName      = HospitalManagementSystem.Utility.GetFeeTypeNameFromId(1833);
                FeeTypeIdInt         = 372;
                FeeTypeSubIDInt      = 0;
            }
            else//bank
            {
                AccountHeadNameParty = "BANK";
                AccountHeadName      = HospitalManagementSystem.Utility.GetFeeTypeNameFromId(1833);
                FeeTypeSubIDInt      = 0;
            }



            var ObjJvDetails = new JVDetail()
            {
                BillNumber      = "",
                CrAmount        = Convert.ToDecimal(0),
                DrAmount        = model.TotalAmount,
                CreatedBy       = HospitalManagementSystem.Utility.GetCurrentLoginUserId(),
                CreatedDate     = DateTime.Today,
                DrOrCr          = "Dr",
                FeeTypeId       = 1833,
                FeeTypeName     = AccountHeadName,
                FeeTypeSubId    = 0,
                JVMasterId      = objJVMaster.JvMasterId,
                Narration       = "Post From stock",
                TransactionDate = DateTime.Today,
            };

            ent.JVDetails.Add(ObjJvDetails);

            //CR Amount

            var ObjJvDetailsCr = new JVDetail()
            {
                BillNumber      = "",
                CrAmount        = model.TotalAmount,
                DrAmount        = Convert.ToDecimal(0),
                CreatedBy       = HospitalManagementSystem.Utility.GetCurrentLoginUserId(),
                CreatedDate     = DateTime.Today,
                DrOrCr          = "Cr",
                FeeTypeId       = FeeTypeIdInt,//Party name (suppliers)
                FeeTypeName     = AccountHeadNameParty,
                FeeTypeSubId    = FeeTypeSubIDInt,
                JVMasterId      = objJVMaster.JvMasterId,
                Narration       = "Post From stock",
                TransactionDate = DateTime.Today,
            };

            ent.JVDetails.Add(ObjJvDetailsCr);


            SetupVoucherNumber vouchernumber = (from x in ent.SetupVoucherNumbers
                                                where x.JvType == "PV" && x.FiscalYear == 7
                                                select x).First();

            vouchernumber.VoucherNo = vouchernumber.VoucherNo + 1;
            ent.SaveChanges();
        }
Пример #8
0
        public int CreateNewJv(JVMasterModel model)
        {
            int i = 0;

            using (EHMSEntities ent = new EHMSEntities())
            {
                int    fiscalyearid     = Utility.GetCurrentFiscalYearID();
                int    VoucherNumberInt = HospitalManagementSystem.Utility.getMaxVoucherNumber(model.JvType, fiscalyearid);
                string VoucherNumber    = model.JvType + "-" + Utility.GetCurrentFiscalYearNameInBS() + "-" + VoucherNumberInt.ToString();
                var    JVMasterObj      = new JVMaster()
                {
                    AccountNumber   = "ac001",
                    BillNumber      = "BN-001",
                    CreatedBy       = Utility.GetCurrentLoginUserId(),
                    CreatedDate     = DateTime.Now,
                    FiscalYearId    = Utility.GetCurrentFiscalYearID(),
                    JvNumber        = VoucherNumber,
                    Narration1      = model.ObjAddMoreParticularsJVModel.Narration,
                    Narration2      = model.ObjAddMoreParticularsJVModel.Narration,
                    Status          = false,
                    JvType          = model.JvType,
                    TotalAmount     = model.ObjAddMoreParticularsJVModel.CrAmountTotal,
                    TransactionDate = DateTime.Now,
                    VerifiedBy      = Utility.GetCurrentLoginUserId(),
                    FormName        = "JV"
                };

                ent.JVMasters.Add(JVMasterObj);

                //JVMasterId Id
                int?JvMasterId = ent.JVMasters.Max(u => (int?)u.JvMasterId);
                if (JvMasterId == null)
                {
                    JvMasterId = 1;
                }
                else
                {
                    JvMasterId = JvMasterId + 1;
                }
                foreach (var item in model.AddMoreParticularsJVModelList)
                {
                    decimal totalDrAmount = 0;
                    decimal totalCrAmount = 0;
                    string  DrOrCrValue   = string.Empty;
                    if (item.DrOrCr == 1)
                    {
                        totalDrAmount = item.DrAmount;
                        DrOrCrValue   = "Dr";
                    }
                    else
                    {
                        totalCrAmount = item.CrAmount;
                        DrOrCrValue   = "Cr";
                    }
                    string AccountHeadName = "";

                    if (item.SubParticulars > 0)
                    {
                        AccountHeadName = HospitalManagementSystem.Utility.GetFeeTypeNameFromId(item.Particulars) + "-" + HospitalManagementSystem.Utility.GetFeeTypeNameFromId(item.SubParticulars);
                    }
                    else
                    {
                        AccountHeadName = HospitalManagementSystem.Utility.GetFeeTypeNameFromId(item.Particulars);
                    }

                    var jvdetailObj = new JVDetail()
                    {
                        BillNumber      = "BL-001",
                        CrAmount        = totalCrAmount,
                        CreatedBy       = Utility.GetCurrentLoginUserId(),
                        CreatedDate     = DateTime.Now,
                        DrAmount        = totalDrAmount,
                        FeeTypeId       = item.Particulars,
                        FeeTypeSubId    = item.SubParticulars,
                        FeeTypeName     = AccountHeadName,
                        JVMasterId      = JVMasterObj.JvMasterId,
                        LinkToDr        = 1,
                        Narration       = model.ObjAddMoreParticularsJVModel.Narration,
                        PaymentType     = "Cash",
                        Status          = false,
                        TransactionDate = DateTime.Now,
                        DrOrCr          = DrOrCrValue
                    };
                    ent.JVDetails.Add(jvdetailObj);
                }

                SetupVoucherNumber vouchernumber = (from x in ent.SetupVoucherNumbers
                                                    where x.JvType == model.JvType && x.FiscalYear == fiscalyearid
                                                    select x).First();
                vouchernumber.VoucherNo = vouchernumber.VoucherNo + 1;

                ent.SaveChanges();

                return(ent.JVMasters.Max(item => item.JvMasterId));
            }
        }
Пример #9
0
        public int SaveComissionJV(JVMasterModel model, string jvDate, string jvEndDate, string Narration)
        {
            int      i                    = 0;
            int      fiscalyearid         = Utility.GetCurrentFiscalYearID();
            DateTime JVTransactionDate    = Convert.ToDateTime(jvDate);
            DateTime JvTransactionEndDate = Convert.ToDateTime(jvEndDate);
            int      VoucherNumberInt     = HospitalManagementSystem.Utility.getMaxVoucherNumber(model.JvType, fiscalyearid);
            string   VoucherNumber        = model.JvType + "-" + Utility.GetCurrentFiscalYearNameInBS() + "-" + VoucherNumberInt.ToString();

            using (EHMSEntities ent = new EHMSEntities())
            {
                decimal totalDrAmount = 0;
                decimal totalCrAmount = 0;
                foreach (var item in model.BillingDetailViewModelList)
                {
                    if (item.Type == "DR")
                    {
                        totalDrAmount += item.Amount;
                    }
                    else
                    {
                        totalCrAmount += item.Amount;
                    }
                }
                var JVMasterObj = new JVMaster()
                {
                    AccountNumber   = "ac001",
                    BillNumber      = "BN-001",
                    CreatedBy       = Utility.GetCurrentLoginUserId(),
                    CreatedDate     = DateTime.Now,
                    FiscalYearId    = Utility.GetCurrentFiscalYearID(),
                    JvNumber        = VoucherNumber,
                    Narration1      = Narration,
                    Narration2      = Narration,
                    Status          = false,
                    JvType          = model.JvType,
                    TotalAmount     = totalDrAmount,
                    TransactionDate = DateTime.Now,
                    VerifiedBy      = Utility.GetCurrentLoginUserId(),
                    FormName        = "Comission"
                };
                ent.JVMasters.Add(JVMasterObj);
                int?JvMasterId = ent.JVMasters.Max(u => (int?)u.JvMasterId);
                if (JvMasterId == null)
                {
                    JvMasterId = 1;
                }
                else
                {
                    JvMasterId = JvMasterId + 1;
                }
                var JVDetails = new JVDetail();
                foreach (var item in model.BillingDetailViewModelList)
                {
                    totalDrAmount = 0;
                    totalCrAmount = 0;
                    string DrOrCrValue = string.Empty;
                    if (item.Type == "DR")
                    {
                        totalDrAmount = item.Amount;
                        DrOrCrValue   = "Dr";
                    }
                    else
                    {
                        totalCrAmount = item.Amount;
                        DrOrCrValue   = "Cr";
                    }
                    if (totalCrAmount > 0 || totalDrAmount > 0)
                    {
                        JVDetails = new JVDetail()
                        {
                            BillNumber      = "BL001",
                            CrAmount        = totalCrAmount,
                            DrAmount        = totalDrAmount,
                            CreatedBy       = Utility.GetCurrentLoginUserId(),
                            CreatedDate     = DateTime.Now,
                            FeeTypeId       = item.AccountHeadID,
                            FeeTypeSubId    = item.AccountSubHeadID,
                            FeeTypeName     = item.HeadName,
                            JVMasterId      = JVMasterObj.JvMasterId,
                            TransactionDate = DateTime.Now,
                            PaymentType     = "",
                            Status          = false,
                            DrOrCr          = DrOrCrValue
                        };
                        ent.JVDetails.Add(JVDetails);
                    }
                }

                var ComDetail = (from x in ent.CommissionDetaislByTypes
                                 where (x.CommissionDate.Year >= JVTransactionDate.Year && x.CommissionDate.Month >= JVTransactionDate.Month && x.CommissionDate.Day >= JVTransactionDate.Day && (x.CommissionDate.Year <= JvTransactionEndDate.Year && x.CommissionDate.Month <= JvTransactionEndDate.Month && x.CommissionDate.Day <= JvTransactionEndDate.Day)) && x.JvStatus == false
                                 select x);
                foreach (CommissionDetaislByType cb in ComDetail)
                {
                    cb.JvStatus = true;
                }

                SetupVoucherNumber vouchernumber = (from x in ent.SetupVoucherNumbers
                                                    where x.JvType == model.JvType &&
                                                    x.FiscalYear == fiscalyearid
                                                    select x).First();
                vouchernumber.VoucherNo = vouchernumber.VoucherNo + 1;

                i = ent.SaveChanges();
                return(i);
            }
        }