Ejemplo n.º 1
0
        public Int64 Update(tblInvGenHead obj, Int32 InvIdno, DataTable DtTemp, string Grtype)
        {
            Int64 InvHeadId = 0;

            using (TransportMandiEntities db = new TransportMandiEntities(MultipleDBDAL.strDynamicConString()))
            {
                db.Connection.Open();
                using (DbTransaction dbTran = db.Connection.BeginTransaction())
                {
                    try
                    {
                        //tblInvGenHead CH = db.tblInvGenHeads.Where(rh => rh.Inv_No == obj.Inv_No && rh.Inv_Idno != InvIdno && rh.Inv_prefix == obj.Inv_prefix && rh.BaseCity_Idno == obj.BaseCity_Idno).FirstOrDefault();
                        //if (CH != null)
                        //{
                        //    InvHeadId = -1;
                        //}
                        //else
                        //{
                        tblInvGenHead TBH = db.tblInvGenHeads.Where(rh => rh.Inv_Idno == InvIdno).FirstOrDefault();
                        if (TBH != null)
                        {
                            TBH.Inv_No                = obj.Inv_No;
                            TBH.Inv_prefix            = obj.Inv_prefix;
                            TBH.Inv_Date              = obj.Inv_Date;
                            TBH.Sendr_Idno            = obj.Sendr_Idno;
                            TBH.BaseCity_Idno         = obj.BaseCity_Idno;
                            TBH.Year_Idno             = obj.Year_Idno;
                            TBH.GrossTot_Amnt         = obj.GrossTot_Amnt;
                            TBH.ServTax_Amnt          = obj.ServTax_Amnt;
                            TBH.Short_Amnt            = obj.Short_Amnt;
                            TBH.Net_Amnt              = obj.Net_Amnt;
                            TBH.Bilty_Chrgs           = obj.Bilty_Chrgs;
                            TBH.TBB_Rate              = obj.TBB_Rate;
                            TBH.TrServTax_Amnt        = obj.TrServTax_Amnt;
                            TBH.TrSwchBrtTax_Amnt     = obj.TrSwchBrtTax_Amnt;
                            TBH.ConsignrServTax       = obj.ConsignrServTax;
                            TBH.TrKisanKalyanTax_Amnt = obj.TrKisanKalyanTax_Amnt;
                            TBH.ConsignrKisanTax_Amnt = obj.ConsignrKisanTax_Amnt;
                            TBH.RoundOff_Amnt         = obj.RoundOff_Amnt;
                            TBH.Admin_Approval        = obj.Admin_Approval;
                            TBH.Print_Format          = obj.Print_Format;
                            TBH.Plant_InDate          = obj.Plant_InDate;
                            TBH.Plant_OutDate         = obj.Plant_OutDate;
                            TBH.Port_InDate           = obj.Port_InDate;
                            TBH.Port_OutDate          = obj.Port_OutDate;
                            TBH.PlantAmount           = obj.PlantAmount;
                            TBH.PortAmount            = obj.PortAmount;
                            TBH.PortDays              = obj.PortDays;
                            TBH.PlantDays             = obj.PlantDays;
                            TBH.HQCharges_Amnt        = obj.HQCharges_Amnt;
                            TBH.AddCharges_Amnt       = obj.AddCharges_Amnt;
                            TBH.Charges1_Name         = obj.Charges1_Name;
                            TBH.Charges1_Amnt         = obj.Charges1_Amnt;
                            TBH.Charges2_Name         = obj.Charges2_Name;
                            TBH.Charges2_Amnt         = obj.Charges2_Amnt;
                            TBH.Date_Modified         = DateTime.Now;
                            TBH.ShtgGST_Amt           = obj.ShtgGST_Amt;
                            TBH.User_ModifiedBy       = obj.User_ModifiedBy;
                            TBH.Delivery_Add          = obj.Delivery_Add;
                            db.SaveChanges();
                            InvHeadId = TBH.Inv_Idno;
                            List <tblInvGenDetl> InvDetl = db.tblInvGenDetls.Where(rd => rd.InvGenHead_Idno == InvIdno).ToList();
                            foreach (tblInvGenDetl rgd in InvDetl)
                            {
                                db.tblInvGenDetls.DeleteObject(rgd);
                                db.SaveChanges();
                            }

                            if (DtTemp.Rows.Count > 0)
                            {
                                foreach (DataRow Dr in DtTemp.Rows)
                                {
                                    tblInvGenDetl objtblInvGenDetl = new tblInvGenDetl();
                                    objtblInvGenDetl.InvGenHead_Idno = InvIdno;
                                    objtblInvGenDetl.GR_Idno         = Convert.ToInt64(Dr["GR_Idno"]);
                                    objtblInvGenDetl.Item_Idno       = Convert.ToInt64(Dr["Item_Idno"]);
                                    objtblInvGenDetl.Item_Rate       = Convert.ToDouble(Dr["Item_Rate"]);
                                    objtblInvGenDetl.Unit_Idno       = Convert.ToInt64(Dr["Unit_Idno"]);
                                    objtblInvGenDetl.Amount          = Convert.ToDouble(Dr["Amount"]);
                                    objtblInvGenDetl.Wayges          = Convert.ToDouble(Dr["Wayges"]);
                                    objtblInvGenDetl.Net_Amnt        = Convert.ToDouble(Dr["Net_Amnt"]);
                                    objtblInvGenDetl.Other_Amnt      = Convert.ToDouble(Dr["Other_Amnt"]);
                                    objtblInvGenDetl.ServTax_Amnt    = Convert.ToDouble(Dr["ServTax_Amnt"]);
                                    objtblInvGenDetl.ServTax_Perc    = Convert.ToDouble(Dr["ServTax_Perc"]);
                                    objtblInvGenDetl.ServTax_Valid   = Convert.ToDouble(Dr["ServTax_Valid"]);
                                    objtblInvGenDetl.SwchBrtTax_Amnt = Convert.ToDouble(Dr["SwchBrtTax_Amnt"]);
                                    objtblInvGenDetl.KisanTax_Amnt   = Convert.ToDouble(Dr["KisanKalyan_Amnt"]);
                                    objtblInvGenDetl.Annexure_No     = Convert.ToString(Dr["Annexure_No"]);
                                    db.tblInvGenDetls.AddObject(objtblInvGenDetl);
                                    db.SaveChanges();
                                }
                            }

                            if (DtTemp.Rows.Count > 0)
                            {
                                if (Grtype == "GR")
                                {
                                    foreach (DataRow Dr in DtTemp.Rows)
                                    {
                                        Int32     GrIdno       = Convert.ToInt32(Dr["GR_Idno"]);
                                        TblGrHead objTblGrHead = (from obj1 in db.TblGrHeads where obj1.GR_Idno == GrIdno select obj1).FirstOrDefault();
                                        objTblGrHead.Billed = true;
                                        db.SaveChanges();
                                    }
                                }
                                else
                                {
                                    foreach (DataRow Dr in DtTemp.Rows)
                                    {
                                        Int32             GrIdno       = Convert.ToInt32(Dr["GR_Idno"]);
                                        tblGrRetailerHead objTblGrHead = (from obj1 in db.tblGrRetailerHeads where obj1.GRRetHead_Idno == GrIdno select obj1).FirstOrDefault();
                                        objTblGrHead.Billed = true;
                                        db.SaveChanges();
                                    }
                                }
                            }
                            dbTran.Commit();
                        }
                    }



                    // }
                    catch
                    {
                        dbTran.Rollback();
                    }
                }
            }
            return(InvHeadId);
        }
Ejemplo n.º 2
0
        public Int64 Insert(tblInvGenHead obj, DataTable DtTemp, string GrType)
        {
            Int64 InvIdno = 0;

            using (TransportMandiEntities db = new TransportMandiEntities(MultipleDBDAL.strDynamicConString()))
            {
                tblChlnBookHead CHead = new tblChlnBookHead();
                db.Connection.Open();
                using (DbTransaction dbTran = db.Connection.BeginTransaction())
                {
                    try
                    {
                        tblInvGenHead RH = db.tblInvGenHeads.Where(rh => rh.Inv_No == obj.Inv_No && rh.Inv_prefix == obj.Inv_prefix && rh.BaseCity_Idno == obj.BaseCity_Idno && rh.Year_Idno == obj.Year_Idno).FirstOrDefault();
                        if (RH != null)
                        {
                            InvIdno = -1;
                        }
                        else
                        {
                            obj.Date_Added    = DateTime.Now;
                            obj.Date_Modified = DateTime.Now;
                            db.tblInvGenHeads.AddObject(obj);

                            db.SaveChanges();
                            InvIdno = obj.Inv_Idno;
                            if (DtTemp.Rows.Count > 0)
                            {
                                foreach (DataRow Dr in DtTemp.Rows)
                                {
                                    tblInvGenDetl objtblInvGenDetl = new tblInvGenDetl();
                                    objtblInvGenDetl.InvGenHead_Idno = InvIdno;
                                    objtblInvGenDetl.GR_Idno         = Convert.ToInt64(Dr["GR_Idno"]);
                                    objtblInvGenDetl.Item_Idno       = Convert.ToInt64(Dr["Item_Idno"]);
                                    objtblInvGenDetl.Item_Rate       = Convert.ToDouble(Dr["Item_Rate"]);
                                    objtblInvGenDetl.Unit_Idno       = Convert.ToInt64(Dr["Unit_Idno"]);
                                    objtblInvGenDetl.Amount          = Convert.ToDouble(Dr["Amount"]);
                                    objtblInvGenDetl.Wayges          = Convert.ToDouble(Dr["Wayges"]);
                                    objtblInvGenDetl.Net_Amnt        = Convert.ToDouble(Dr["Net_Amnt"]);
                                    objtblInvGenDetl.Other_Amnt      = Convert.ToDouble(Dr["Other_Amnt"]);
                                    objtblInvGenDetl.ServTax_Amnt    = Convert.ToDouble(Dr["ServTax_Amnt"]);
                                    objtblInvGenDetl.ServTax_Perc    = Convert.ToDouble(Dr["ServTax_Perc"]);
                                    objtblInvGenDetl.ServTax_Valid   = Convert.ToDouble(Dr["ServTax_Valid"]);
                                    objtblInvGenDetl.SwchBrtTax_Amnt = Convert.ToDouble(Dr["SwchBrtTax_Amnt"]);
                                    objtblInvGenDetl.KisanTax_Amnt   = Convert.ToDouble(Dr["KisanKalyan_Amnt"]);
                                    //#GST
                                    objtblInvGenDetl.SGST_Amt    = Convert.ToDouble(Dr["SGST_Amt"]);
                                    objtblInvGenDetl.CGST_Amt    = Convert.ToDouble(Dr["CGST_Amt"]);
                                    objtblInvGenDetl.IGST_Amt    = Convert.ToDouble(Dr["IGST_Amt"]);
                                    objtblInvGenDetl.Annexure_No = Convert.ToString(Dr["Annexure_No"]);
                                    db.tblInvGenDetls.AddObject(objtblInvGenDetl);
                                    db.SaveChanges();
                                }
                            }
                            if (DtTemp.Rows.Count > 0)
                            {
                                if (GrType == "GR")
                                {
                                    foreach (DataRow Dr in DtTemp.Rows)
                                    {
                                        Int32     GrIdno       = Convert.ToInt32(Dr["GR_Idno"]);
                                        TblGrHead objTblGrHead = (from obj1 in db.TblGrHeads where obj1.GR_Idno == GrIdno select obj1).FirstOrDefault();
                                        objTblGrHead.Billed = true;
                                        db.SaveChanges();
                                    }
                                }
                                else
                                {
                                    foreach (DataRow Dr in DtTemp.Rows)
                                    {
                                        Int32             GrIdno       = Convert.ToInt32(Dr["GR_Idno"]);
                                        tblGrRetailerHead objTblGrHead = (from obj1 in db.tblGrRetailerHeads where obj1.GRRetHead_Idno == GrIdno select obj1).FirstOrDefault();
                                        objTblGrHead.Billed = true;
                                        db.SaveChanges();
                                    }
                                }
                            }

                            dbTran.Commit();
                        }
                    }
                    catch
                    {
                        dbTran.Rollback();
                    }
                }

                return(InvIdno);
            }
        }