Пример #1
0
        public Int64 Insert(tblAmntRecvdHireInv_Head obj, DataTable Dttemp)
        {
            Int64 AmntHeadId = 0;

            using (TransportMandiEntities db = new TransportMandiEntities(MultipleDBDAL.strDynamicConString()))
            {
                tblAmntRecvdInv_Head AmtHead = new tblAmntRecvdInv_Head();
                db.Connection.Open();
                // using (DbTransaction dbTran = db.Connection.BeginTransaction())
                // {
                try
                {
                    tblAmntRecvdHireInv_Head RH = db.tblAmntRecvdHireInv_Head.Where(rh => rh.Rcpt_No == obj.Rcpt_No && rh.Year_IdNo == obj.Year_IdNo).FirstOrDefault();
                    if (RH != null)
                    {
                        AmntHeadId = -1;
                    }
                    else
                    {
                        db.tblAmntRecvdHireInv_Head.AddObject(obj);

                        db.SaveChanges();
                        AmntHeadId = obj.HireInvHead_Idno;
                        if (Dttemp != null && Dttemp.Rows.Count > 0)
                        {
                            foreach (DataRow Dr in Dttemp.Rows)
                            {
                                if (Convert.ToDouble(Dr["Recv_Amount"]) > 0 || Convert.ToDouble(Dr["TDS_Amnt"]) > 0 || Convert.ToDouble(Dr["Dr_Note"]) > 0)
                                {
                                    tblAmntRecvdHireInv_Detl objtblAmntRecvHIreInv_Detl = new tblAmntRecvdHireInv_Detl();
                                    //objtblAmntRecvInv_Detl.InvDetl_Idno = Convert.ToInt32(Dr["InvDetl_Idno"]);
                                    objtblAmntRecvHIreInv_Detl.InvHead_Idno = Convert.ToInt64(AmntHeadId);
                                    objtblAmntRecvHIreInv_Detl.Inv_Idno     = Convert.ToInt64(Dr["Inv_Idno"]);
                                    objtblAmntRecvHIreInv_Detl.Inv_No       = Convert.ToString(Dr["Inv_No"]);
                                    objtblAmntRecvHIreInv_Detl.Inv_Date     = Convert.ToDateTime(Dr["Inv_Date"]);
                                    objtblAmntRecvHIreInv_Detl.Recivr_Idno  = Convert.ToInt64(Dr["Recivr_Idno"]);
                                    objtblAmntRecvHIreInv_Detl.Inv_Amnt     = Convert.ToDouble(Dr["Amount"]);
                                    objtblAmntRecvHIreInv_Detl.Recvd_Amnt   = Convert.ToDouble(Dr["Recv_Amount"]);
                                    objtblAmntRecvHIreInv_Detl.TDS_Amnt     = Convert.ToDouble(Dr["TDS_Amnt"]);
                                    objtblAmntRecvHIreInv_Detl.Dr_Note      = Convert.ToDouble(Dr["Dr_Note"]);
                                    objtblAmntRecvHIreInv_Detl.Cur_Bal      = Convert.ToDouble(Dr["Cur_Bal"]);
                                    objtblAmntRecvHIreInv_Detl.Tot_Recvd    = Convert.ToDouble(Dr["Tot_Recvd"]);
                                    db.tblAmntRecvdHireInv_Detl.AddObject(objtblAmntRecvHIreInv_Detl);
                                    db.SaveChanges();
                                }
                            }
                            // dbTran.Commit();
                        }
                    }
                }
                catch
                {
                    //dbTran.Rollback();
                }
                //     }
                return(AmntHeadId);
            }
        }
Пример #2
0
        public int Delete(Int64 HeadId, Int64 UserIdno, string con)
        {
            clsAccountPosting objclsAccountPosting = new clsAccountPosting();
            int value = 0;

            using (TransportMandiEntities db = new TransportMandiEntities(MultipleDBDAL.strDynamicConString()))
            {
                tblAmntRecvdHireInv_Head        CH = db.tblAmntRecvdHireInv_Head.Where(h => h.HireInvHead_Idno == HeadId).FirstOrDefault();
                List <tblAmntRecvdHireInv_Detl> CD = db.tblAmntRecvdHireInv_Detl.Where(d => d.InvHead_Idno == HeadId).ToList();
                if (CH != null)
                {
                    //SqlParameter[] objSqlPara = new SqlParameter[3];
                    //objSqlPara[0] = new SqlParameter("@Action", "DeleteAmntRcvdAgnstInvDet");
                    //objSqlPara[1] = new SqlParameter("@Idno", HeadId);
                    //objSqlPara[2] = new SqlParameter("@UserIdno", UserIdno);
                    //Int32 del = SqlHelper.ExecuteNonQuery(con, CommandType.StoredProcedure, "spDeleteFunctionality", objSqlPara);

                    foreach (var d in CD)
                    {
                        db.tblAmntRecvdHireInv_Detl.DeleteObject(d);

                        db.SaveChanges();
                    }
                    db.tblAmntRecvdHireInv_Head.DeleteObject(CH);
                    Int64 intValue = objclsAccountPosting.DeleteAccountPosting(HeadId, "ARIV");

                    db.SaveChanges();

                    if (intValue > 0)
                    {
                        value = 1;
                    }
                }
            }
            return(value);
        }
Пример #3
0
        public Int64 Update(tblAmntRecvdHireInv_Head obj, Int32 Head_Idno, DataTable Dttemp)
        {
            Int64 AmntHeadId = 0;

            using (TransportMandiEntities db = new TransportMandiEntities(MultipleDBDAL.strDynamicConString()))
            {
                db.Connection.Open();
                //  using (DbTransaction dbTran = db.Connection.BeginTransaction())
                // {
                try
                {
                    tblAmntRecvdHireInv_Head CH = db.tblAmntRecvdHireInv_Head.Where(rh => rh.Rcpt_No == obj.Rcpt_No && rh.HireInvHead_Idno != Head_Idno && rh.Year_IdNo == obj.Year_IdNo).FirstOrDefault();
                    if (CH != null)
                    {
                        AmntHeadId = -1;
                    }
                    else
                    {
                        tblAmntRecvdHireInv_Head TBH = db.tblAmntRecvdHireInv_Head.Where(rh => rh.HireInvHead_Idno == Head_Idno).FirstOrDefault();
                        if (TBH != null)
                        {
                            TBH.Rcpt_No       = obj.Rcpt_No;
                            TBH.FromCity_Idno = obj.FromCity_Idno;
                            TBH.Rcpt_date     = obj.Rcpt_date;
                            TBH.Year_IdNo     = obj.Year_IdNo;
                            TBH.RcptType_Idno = obj.RcptType_Idno;
                            TBH.Party_IdNo    = obj.Party_IdNo;
                            TBH.Inst_No       = obj.Inst_No;
                            TBH.Inst_Dt       = obj.Inst_Dt;
                            TBH.Bank_Idno     = obj.Bank_Idno;
                            TBH.Comp_Idno     = obj.Comp_Idno;
                            TBH.Remark        = obj.Remark;
                            TBH.Status        = obj.Status;
                            TBH.Date_Modified = obj.Date_Modified;
                            TBH.Net_Amnt      = obj.Net_Amnt;
                            db.SaveChanges();
                            AmntHeadId = TBH.HireInvHead_Idno;
                            List <tblAmntRecvInv_Detl> ChlnDetl = db.tblAmntRecvInv_Detl.Where(rd => rd.InvHead_Idno == Head_Idno).ToList();
                            foreach (tblAmntRecvInv_Detl rgd in ChlnDetl)
                            {
                                db.tblAmntRecvInv_Detl.DeleteObject(rgd);
                                db.SaveChanges();
                            }
                            if (Dttemp != null && Dttemp.Rows.Count > 0)
                            {
                                foreach (DataRow Dr in Dttemp.Rows)
                                {
                                    tblAmntRecvInv_Detl objtblAmntRecvInv_Detl = new tblAmntRecvInv_Detl();

                                    //objtblAmntRecvInv_Detl.InvDetl_Idno = Convert.ToInt32(Dr["InvDetl_Idno"]);
                                    if (Convert.ToDouble(Dr["Recv_Amount"]) > 0 || Convert.ToDouble(Dr["TDS_Amnt"]) > 0 || Convert.ToDouble(Dr["Dr_Note"]) > 0)
                                    {
                                        objtblAmntRecvInv_Detl.InvHead_Idno = Head_Idno;
                                        objtblAmntRecvInv_Detl.Inv_Idno     = Convert.ToInt64(Dr["Inv_Idno"]);
                                        objtblAmntRecvInv_Detl.Inv_No       = Convert.ToString(Dr["Inv_No"]);
                                        objtblAmntRecvInv_Detl.Inv_Date     = Convert.ToDateTime(Dr["Inv_Date"]);
                                        objtblAmntRecvInv_Detl.Recivr_Idno  = Convert.ToInt64(Dr["Recivr_Idno"]);
                                        objtblAmntRecvInv_Detl.Inv_Amnt     = Convert.ToDouble(Dr["Amount"]);
                                        objtblAmntRecvInv_Detl.Recvd_Amnt   = Convert.ToDouble(Dr["Recv_Amount"]);
                                        objtblAmntRecvInv_Detl.TDS_Amnt     = Convert.ToDouble(Dr["TDS_Amnt"]);
                                        objtblAmntRecvInv_Detl.Dr_Note      = Convert.ToDouble(Dr["Dr_Note"]);
                                        objtblAmntRecvInv_Detl.Cur_Bal      = Convert.ToDouble(Dr["Cur_Bal"]);
                                        objtblAmntRecvInv_Detl.Tot_Recvd    = Convert.ToDouble(Dr["Tot_Recvd"]);
                                        objtblAmntRecvInv_Detl.Vchr_RecAmnt = Convert.ToDouble(Dr["Vchr_Amnt"]);
                                        db.tblAmntRecvInv_Detl.AddObject(objtblAmntRecvInv_Detl);
                                        db.SaveChanges();
                                    }
                                }
                            }

                            // dbTran.Commit();
                        }
                    }
                }
                catch
                {
                    // dbTran.Rollback();
                }
                //  }
            }
            return(AmntHeadId);
        }