//---------------------------------
 public Int64 Insert(Int64 User_idno, Int64 FromCity_idno, Int64 yearidno, Int64 cityid, Int64 stateid, Int64 Sender, Int64 Item, Int64 unit, Int32 STax_Typ, Int64 Gr_Typ)
 {
     using (TransportMandiEntities db = new TransportMandiEntities(MultipleDBDAL.strDynamicConString()))
     {
         UserDefaultDAL objDAL        = new UserDefaultDAL();
         Int64          Value         = 0;
         tblUserDefault objUsrDefault = new tblUserDefault();
         objUsrDefault.User_idno     = User_idno;
         objUsrDefault.FromCity_idno = FromCity_idno;
         objUsrDefault.Year_idno     = yearidno;
         objUsrDefault.CityId        = cityid;
         objUsrDefault.StateId       = stateid;
         objUsrDefault.Date_Added    = MultipleDBDAL.GetIndianDateTime().Date;
         objUsrDefault.SenderIdno    = Sender;
         objUsrDefault.ItemIdno      = Item;
         objUsrDefault.UnitIdno      = unit;
         objUsrDefault.STax_Typ      = STax_Typ;
         objUsrDefault.Gr_Type       = Gr_Typ;
         db.AddTotblUserDefaults(objUsrDefault);
         db.SaveChanges();
         Value  = objUsrDefault.UserDefault_Idno;
         objDAL = null;
         return(Value);
     }
 }
Esempio n. 2
0
        public Int64 UpdateMtrlRcptHOHead(tblChlnDelvHead objMtrlRcptHOHead, DataTable DtTemp, Int32 HeadIdno)
        {
            Int64 RcptHeadIdno = HeadIdno;

            try
            {
                using (TransportMandiEntities db = new TransportMandiEntities(MultipleDBDAL.strDynamicConString()))
                {
                    tblChlnDelvHead RH = db.tblChlnDelvHeads.Where(rh => (rh.ChlnTransf_Idno == objMtrlRcptHOHead.ChlnTransf_Idno) && (rh.ToCity_Idno == objMtrlRcptHOHead.ToCity_Idno) && (rh.Year_Idno == objMtrlRcptHOHead.Year_Idno) && (rh.ChlnDelvHead_Idno != HeadIdno)).FirstOrDefault();
                    if (RH != null)
                    {
                        RcptHeadIdno = -1;
                    }
                    else
                    {
                        tblChlnDelvHead objRcptHOHead = (from obj in db.tblChlnDelvHeads
                                                         where obj.ChlnDelvHead_Idno == RcptHeadIdno
                                                         select obj).SingleOrDefault();
                        if (objRcptHOHead != null)
                        {
                            objRcptHOHead.ChlnDelv_Date   = objMtrlRcptHOHead.ChlnDelv_Date;
                            objRcptHOHead.ToCity_Idno     = objMtrlRcptHOHead.ToCity_Idno;
                            objRcptHOHead.ChlnTransf_Idno = objMtrlRcptHOHead.ChlnTransf_Idno;
                            objRcptHOHead.LocGR_Amnt      = objMtrlRcptHOHead.LocGR_Amnt;
                            objRcptHOHead.CrsngGR_Amnt    = objMtrlRcptHOHead.CrsngGR_Amnt;
                            objRcptHOHead.Net_Amnt        = objMtrlRcptHOHead.Net_Amnt;
                            objRcptHOHead.Date_Modified   = MultipleDBDAL.GetIndianDateTime().Date; // DateTime.Now.Date;
                            objRcptHOHead.Year_Idno       = objMtrlRcptHOHead.Year_Idno;
                            db.SaveChanges();
                        }

                        List <tblChlnDelvDetl> ChlnDetl = db.tblChlnDelvDetls.Where(rd => rd.ChlnDelvHead_Idno == RcptHeadIdno).ToList();
                        foreach (tblChlnDelvDetl rgd in ChlnDetl)
                        {
                            db.tblChlnDelvDetls.DeleteObject(rgd);
                            db.SaveChanges();
                        }


                        if (DtTemp.Rows.Count > 0)
                        {
                            foreach (DataRow Dr in DtTemp.Rows)
                            {
                                tblChlnDelvDetl objtblChlnDelvDetl = new tblChlnDelvDetl();
                                objtblChlnDelvDetl.Gr_Idno           = Convert.ToInt32(Dr["Gr_Idno"]);
                                objtblChlnDelvDetl.Item_Idno         = Convert.ToInt32(Dr["Item_Idno"]);
                                objtblChlnDelvDetl.Unit_Idno         = Convert.ToInt32(Dr["Unit_Idno"]);
                                objtblChlnDelvDetl.Rate_Type         = Convert.ToInt32(Dr["Rate_Type"]);
                                objtblChlnDelvDetl.Qty               = Convert.ToInt32(Dr["Qty"]);
                                objtblChlnDelvDetl.Weight            = Convert.ToDouble(Dr["Weight"]);
                                objtblChlnDelvDetl.Amount            = Convert.ToDouble(Dr["Amount"]);
                                objtblChlnDelvDetl.Reamrk            = Convert.ToString(Dr["Reamrk"]);
                                objtblChlnDelvDetl.Delv_Qty          = Convert.ToDouble(Dr["Delv_Qty"]);
                                objtblChlnDelvDetl.Delv_Weight       = Convert.ToDouble(Dr["Delv_Wt"]);
                                objtblChlnDelvDetl.Delv_Amount       = Convert.ToDouble(Dr["Delv_Amount"]);
                                objtblChlnDelvDetl.Reamrk            = Convert.ToString(Dr["Reamrk"]);
                                objtblChlnDelvDetl.ChlnDelvHead_Idno = RcptHeadIdno;
                                db.tblChlnDelvDetls.AddObject(objtblChlnDelvDetl);
                                db.SaveChanges();
                            }
                        }
                        if (DtTemp.Rows.Count > 0)
                        {
                            foreach (DataRow Dr in DtTemp.Rows)
                            {
                                Int32 GrIdno = 0;
                                GrIdno = Convert.ToInt32(Dr["Gr_Idno"]);
                                TblGrHead objTblGrHead = (from obj in db.TblGrHeads where obj.GR_Idno == GrIdno select obj).FirstOrDefault();
                                if (objTblGrHead != null)
                                {
                                    objTblGrHead.Gr_Delv       = true;
                                    objTblGrHead.ChlnDelv_Idno = RcptHeadIdno;
                                    db.SaveChanges();
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
            }
            return(RcptHeadIdno);
        }