public int Delete(Int64 HeadId, Int64 UserIdno, string con)
        {
            int value = 0;

            using (TransportMandiEntities db = new TransportMandiEntities(MultipleDBDAL.strDynamicConString()))
            {
                clsAccountPosting              objclsAccountPosting = new clsAccountPosting();
                tblChlnAmntPayment_Head        CH = db.tblChlnAmntPayment_Head.Where(h => h.Id == HeadId).FirstOrDefault();
                List <tblChlnAmntPayment_Detl> CD = db.tblChlnAmntPayment_Detl.Where(d => d.Head_Idno == HeadId).ToList();
                if (CH != null)
                {
                    SqlParameter[] objSqlPara = new SqlParameter[3];
                    objSqlPara[0] = new SqlParameter("@Action", "DeleteChlnAmntPayment");
                    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.tblChlnAmntPayment_Detl.DeleteObject(d);
                        db.SaveChanges();
                    }
                    db.tblChlnAmntPayment_Head.DeleteObject(CH);
                    Int64 intValue = objclsAccountPosting.DeleteAccountPosting(HeadId, "ACB");
                    db.SaveChanges();
                    if (intValue > 0)
                    {
                        value = 1;
                    }
                }
            }
            return(value);
        }
Ejemplo n.º 2
0
        public int Delete(Int64 HeadId)
        {
            int value = 0;

            using (TransportMandiEntities db = new TransportMandiEntities(MultipleDBDAL.strDynamicConString()))
            {
                clsAccountPosting      objclsAccountPosting = new clsAccountPosting();
                tblChlnBookHead        CH = db.tblChlnBookHeads.Where(h => h.Chln_Idno == HeadId).FirstOrDefault();
                List <tblChlnBookDetl> CD = db.tblChlnBookDetls.Where(d => d.ChlnBookHead_Idno == HeadId).ToList();
                if (CH != null)
                {
                    foreach (var d in CD)
                    {
                        TblGrHead objTblGrHead = (from obj in db.TblGrHeads where obj.GR_Idno == d.GR_Idno select obj).FirstOrDefault();
                        objTblGrHead.Chln_Idno = 0;
                        db.SaveChanges();
                    }

                    foreach (var d in CD)
                    {
                        db.tblChlnBookDetls.DeleteObject(d);
                        db.SaveChanges();
                    }
                    db.tblChlnBookHeads.DeleteObject(CH);

                    TblGrHead        GrHEad = db.TblGrHeads.Where(rd => rd.Chln_Idno == Convert.ToInt32(HeadId)).FirstOrDefault();
                    List <TblGrDetl> GrDetl = db.TblGrDetls.Where(rd => rd.GrHead_Idno == GrHEad.GR_Idno).ToList();
                    foreach (TblGrDetl rgd in GrDetl)
                    {
                        db.TblGrDetls.DeleteObject(rgd);
                        db.SaveChanges();
                    }

                    db.TblGrHeads.DeleteObject(GrHEad);
                    db.SaveChanges();


                    Int64 intValue = objclsAccountPosting.DeleteAccountPosting(HeadId, "CB");
                    db.SaveChanges();
                    if (intValue > 0)
                    {
                        value = 1;
                    }
                }
            }
            return(value);
        }
Ejemplo n.º 3
0
        public int Delete(Int64 HeadId, Int64 UserIdno, string con)
        {
            int value = 0; clsAccountPosting objclsAccountPosting = new clsAccountPosting();

            using (TransportMandiEntities db = new TransportMandiEntities(MultipleDBDAL.strDynamicConString()))
            {
                tblInvGenHead        CH = db.tblInvGenHeads.Where(h => h.Inv_Idno == HeadId).FirstOrDefault();
                List <tblInvGenDetl> CD = db.tblInvGenDetls.Where(d => d.InvGenHead_Idno == HeadId).ToList();
                if (CD != null && CH != null)
                {
                    var lst = (from AI in db.tblAmntRecvInv_Detl where AI.Inv_Idno == HeadId select AI).ToList();

                    if (lst != null && lst.Count > 0)
                    {
                        return(-1);
                    }
                    else
                    {
                        if (CH != null)
                        {
                            SqlParameter[] objSqlPara = new SqlParameter[3];
                            objSqlPara[0] = new SqlParameter("@Action", "DeleteInvoiceDetails");
                            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.tblInvGenDetls.DeleteObject(d);
                                db.SaveChanges();
                            }
                            db.tblInvGenHeads.DeleteObject(CH);
                            db.SaveChanges();
                            Int64 intValue = objclsAccountPosting.DeleteAccountPosting(HeadId, "IB");
                            db.SaveChanges();
                            if (intValue > 0)
                            {
                                value = 1;
                            }
                        }
                    }
                }
            }
            return(value);
        }
Ejemplo n.º 4
0
        public int DeletePurchaseBill(int PBillHead_Idno)
        {
            int value = 0;

            using (TransportMandiEntities db = new TransportMandiEntities(MultipleDBDAL.strDynamicConString()))
            {
                tblPBillHead        pbh    = db.tblPBillHeads.Where(h => h.PBillHead_Idno == PBillHead_Idno).FirstOrDefault();
                List <tblPBillDetl> qtd    = db.tblPBillDetls.Where(d => d.PBillHead_Idno == PBillHead_Idno).ToList();
                List <Stckdetl>     StDetl = db.Stckdetls.Where(d => d.PBillIdno == PBillHead_Idno && d.MtrlIssue_Idno == 0 && d.Is_Issued == false).ToList();
                if (pbh.Billed == true)
                {
                    return(value = -1);
                }
                if (pbh != null)
                {
                    foreach (var d in qtd)
                    {
                        db.tblPBillDetls.DeleteObject(d);
                        db.SaveChanges();
                    }
                    db.tblPBillHeads.DeleteObject(pbh);
                    db.SaveChanges();
                    value = 1;
                }
                if (StDetl != null)
                {
                    foreach (var S in StDetl)
                    {
                        db.Stckdetls.DeleteObject(S);
                        db.SaveChanges();
                    }
                    //value = 1;
                }
                clsAccountPosting objclsAccountPosting = new clsAccountPosting();
                Int64             intValue             = objclsAccountPosting.DeleteAccountPosting(PBillHead_Idno, "PB");
                db.SaveChanges();
                if (intValue > 0)
                {
                    value = 1;
                }
            }
            return(value);
        }
Ejemplo n.º 5
0
        public int Delete(int intFuelSlipIdno)
        {
            int intValue = 0;

            try
            {
                using (TransportMandiEntities db = new TransportMandiEntities(MultipleDBDAL.strDynamicConString()))
                {
                    tblFuelSlipHead objItemMast = (from mast in db.tblFuelSlipHeads
                                                   where mast.FuelSlip_Idno == intFuelSlipIdno
                                                   select mast).FirstOrDefault();
                    if (objItemMast != null)
                    {
                        db.tblFuelSlipHeads.DeleteObject(objItemMast);
                        db.SaveChanges();
                        intValue = 1;
                    }
                    List <tblFuelSlipDetl> Detl = (from M in db.tblFuelSlipDetls where M.FuelSlipHead_Idno == intFuelSlipIdno select M).ToList();
                    if (Detl != null && Detl.Count > 0)
                    {
                        foreach (var D in Detl)
                        {
                            db.tblFuelSlipDetls.DeleteObject(D);
                        }
                        db.SaveChanges();
                    }
                    clsAccountPosting objclsAccountPosting = new clsAccountPosting();
                    objclsAccountPosting.DeleteAccountPosting(intFuelSlipIdno, "FS");
                    intValue = 1;
                }
            }
            catch (Exception Ex)
            {
                if (Convert.ToBoolean(Ex.InnerException.Message.Contains("The DELETE statement conflicted with the REFERENCE constraint")) == true)
                {
                    intValue = -1;
                }
            }
            return(intValue);
        }
Ejemplo n.º 6
0
        public int Delete(Int64 HeadId)
        {
            clsAccountPosting objclsAccountPosting = new clsAccountPosting();
            int value = 0;

            using (TransportMandiEntities db = new TransportMandiEntities(MultipleDBDAL.strDynamicConString()))
            {
                tblSBillHead        qth = db.tblSBillHeads.Where(h => h.SBillHead_Idno == HeadId).FirstOrDefault();
                List <tblSBillDetl> qtd = db.tblSBillDetls.Where(d => d.SBillHead_Idno == HeadId).ToList();
                if (qth != null)
                {
                    foreach (var d in qtd)
                    {
                        db.tblSBillDetls.DeleteObject(d);
                        db.SaveChanges();
                    }
                    db.tblSBillHeads.DeleteObject(qth);
                    Int64 intValue = objclsAccountPosting.DeleteAccountPosting(HeadId, "SB");
                    db.SaveChanges();
                    value = 1;
                }
            }
            return(value);
        }