Exemplo n.º 1
0
        public List <ReceviedVoucherModel> GetReceviedVoucherbyId(int id)
        {
            List <ReceviedVoucherModel> lstRecevied = new List <ReceviedVoucherModel>();
            ReceviedVoucherModel        objRecevied;

            string Query = "SELECT * FROM Recevied_Voucher WHERE Recevied_Id=" + id;

            System.Data.IDataReader dr = _dbHelper.ExecuteDataReader(Query, _dbHelper.GetConnObject());

            while (dr.Read())
            {
                objRecevied = new ReceviedVoucherModel();

                objRecevied.RV_Id         = DataFormat.GetInteger(dr["Recevied_ID"]);
                objRecevied.Date          = DataFormat.GetDateTime(dr["Recevied_Date"]);
                objRecevied.Series        = dr["Series"].ToString();
                objRecevied.issuingoffice = dr["Issuing Office"].ToString();
                objRecevied.fromNo        = DataFormat.GetInteger(dr["FromNo"]);
                objRecevied.party         = dr["Party"].ToString();
                objRecevied.issuedDate    = DataFormat.GetDateTime(dr["DateOfIssue"]);
                objRecevied.stateofissue  = dr["StateOfIssue"].ToString();
                objRecevied.Narration     = dr["Narration"].ToString();


                //SELECT Recevied Amount Voucher

                string itemQuery = "SELECT * FROM Recevied_Amount_Voucher WHERE Recevied_Id=" + id;
                System.Data.IDataReader drRec = _dbHelper.ExecuteDataReader(itemQuery, _dbHelper.GetConnObject());

                objRecevied.ReceviedModel = new List <ReceviedModel>();
                ReceviedModel objrec;

                while (drRec.Read())
                {
                    objrec = new ReceviedModel();

                    objrec.id        = DataFormat.GetInteger(drRec["SNo"]);
                    objrec.ParentId  = DataFormat.GetInteger(drRec["Recevied_ID"]);
                    objrec.VoucherNo = DataFormat.GetInteger(drRec["VoucherNo"]);
                    objrec.Dated     = drRec["Dated"].ToString();
                    objrec.Amount    = Convert.ToDecimal(drRec["Amount"]);


                    objRecevied.ReceviedModel.Add(objrec);
                }

                lstRecevied.Add(objRecevied);
            }
            return(lstRecevied);
        }
Exemplo n.º 2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            ReceviedVoucherModel objissued = new ReceviedVoucherModel();

            objissued.Date          = Convert.ToDateTime(dtDate.Text);
            objissued.form          = tbxForm.Text.Trim();
            objissued.fromNo        = Convert.ToInt32(tbxFormNumber.Text);
            objissued.Series        = tbxSeries.Text.Trim();
            objissued.issuingoffice = tbxIssingoffice.Text.Trim();
            objissued.issuedDate    = Convert.ToDateTime(dtDateIssue.Text);
            objissued.Narration     = tbxNarration.Text.Trim();
            objissued.stateofissue  = tbxStateIssue.Text.Trim();
            objissued.party         = tbxParty.Text.Trim();

            //Form Recevied Details
            ReceviedModel        objModel;
            List <ReceviedModel> lstIssued = new List <ReceviedModel>();

            for (int i = 0; i < gdvFormsRcvd.DataRowCount; i++)
            {
                DataRow row = gdvFormsRcvd.GetDataRow(i);

                objModel           = new ReceviedModel();
                objModel.VoucherNo = Convert.ToInt32(row["VoucherNumber"]);
                objModel.Dated     = row["Dated"].ToString();
                objModel.Amount    = Convert.ToInt32(row["Amount"].ToString());

                lstIssued.Add(objModel);
            }

            objissued.ReceviedModel = lstIssued;

            bool isSuccess = objrcvdbl.SaveReceviedVoucher(objissued);

            if (isSuccess)
            {
                MessageBox.Show("Saved Successfully!");
                //   Dialogs.PopUPDialog d = new Dialogs.PopUPDialog("Saved Successfully!");
                // d.ShowDialog();
            }
        }
Exemplo n.º 3
0
        public bool SaveReceviedVoucher(ReceviedVoucherModel objRecevied)
        {
            string Query   = string.Empty;
            bool   isSaved = true;

            try
            {
                DBParameterCollection paramCollection = new DBParameterCollection();

                paramCollection.Add(new DBParameter("@Date", objRecevied.Date, System.Data.DbType.DateTime));
                paramCollection.Add(new DBParameter("@Series", objRecevied.Series));
                paramCollection.Add(new DBParameter("@IssuingOffice", objRecevied.issuingoffice));
                paramCollection.Add(new DBParameter("@FromNo", objRecevied.fromNo));
                paramCollection.Add(new DBParameter("@Party", objRecevied.party));
                paramCollection.Add(new DBParameter("@DateOfIssue", objRecevied.issuedDate, System.Data.DbType.DateTime));
                paramCollection.Add(new DBParameter("@StateOfIssue", objRecevied.stateofissue));
                paramCollection.Add(new DBParameter("@Narration", objRecevied.Narration));

                paramCollection.Add(new DBParameter("@CreatedBy", "Admin"));
                //paramCollection.Add(new DBParameter("@CreatedDate", DateTime.Now));

                Query = "INSERT INTO Recevied_Voucher([Recevied_Date],[Series],[Issuing Office],[FromNo],[Party],[DateOfIssue]," +
                        "[StateOfIssue],[Narration],[CreatedBy]) VALUES " +
                        "(@Date,@Series,@IssuingOffice,@FromNo,@Party,@DateOfIssue,@StateOfIssue,@Narration," +
                        " @CreatedBy)";

                if (_dbHelper.ExecuteNonQuery(Query, paramCollection) > 0)
                {
                    SaveReceviedAccount(objRecevied.ReceviedModel);
                    isSaved = true;
                }
            }
            catch (Exception ex)
            {
                isSaved = false;
                throw ex;
            }

            return(isSaved);
        }
Exemplo n.º 4
0
        public bool SaveReceviedVoucher(ReceviedVoucherModel objRecevied)
        {
            string Query   = string.Empty;
            bool   isSaved = true;

            try
            {
                DBParameterCollection paramCollection = new DBParameterCollection();

                paramCollection.Add(new DBParameter("@Date", objRecevied.Date, System.Data.DbType.DateTime));
                paramCollection.Add(new DBParameter("@Form", objRecevied.form));
                paramCollection.Add(new DBParameter("@Series", objRecevied.Series));
                paramCollection.Add(new DBParameter("@Issuingoffice", objRecevied.issuingoffice));
                paramCollection.Add(new DBParameter("@Formnumber", objRecevied.fromNo));
                paramCollection.Add(new DBParameter("@DateofIssue", objRecevied.issuedDate, System.Data.DbType.DateTime));
                paramCollection.Add(new DBParameter("@Stateofissue", objRecevied.stateofissue));
                paramCollection.Add(new DBParameter("@Party", objRecevied.party));
                paramCollection.Add(new DBParameter("@Narration", objRecevied.Narration));
                paramCollection.Add(new DBParameter("@TotalAmount", "0"));

                paramCollection.Add(new DBParameter("@CreatedBy", "Admin"));

                System.Data.IDataReader dr =
                    _dbHelper.ExecuteDataReader("spInsertFormRcvdMaster", _dbHelper.GetConnObject(), paramCollection, System.Data.CommandType.StoredProcedure);

                int id = 0;
                dr.Read();
                id = Convert.ToInt32(dr[0]);
                SaveReceviedDetails(objRecevied.ReceviedModel, id);
            }
            catch (Exception ex)
            {
                isSaved = false;
                throw ex;
            }

            return(isSaved);
        }
Exemplo n.º 5
0
        //Udate Recevied Voucher
        public bool UpdateReceviedVoucher(ReceviedVoucherModel objRecevied)
        {
            string Query     = string.Empty;
            bool   isUpdated = true;

            try
            {
                //UPDATE Recevied TABLE - PARENT TABLE

                DBParameterCollection paramCollection = new DBParameterCollection();

                paramCollection.Add(new DBParameter("@Date", objRecevied.Date, System.Data.DbType.DateTime));
                paramCollection.Add(new DBParameter("@Series", objRecevied.Series));
                paramCollection.Add(new DBParameter("@IssuingOffice", objRecevied.issuingoffice));
                paramCollection.Add(new DBParameter("@FromNo", objRecevied.fromNo));
                paramCollection.Add(new DBParameter("@Party", objRecevied.party));
                paramCollection.Add(new DBParameter("@DateOfIssue", objRecevied.issuedDate, System.Data.DbType.DateTime));
                paramCollection.Add(new DBParameter("@StateOfIssue", objRecevied.stateofissue));
                paramCollection.Add(new DBParameter("@Narration", objRecevied.Narration));

                paramCollection.Add(new DBParameter("@ModifiedBy", "Admin"));
                paramCollection.Add(new DBParameter("@id", objRecevied.RV_Id));
                //paramCollection.Add(new DBParameter("@CreatedDate", DateTime.Now));

                Query = "UPDATE Recevied_Voucher SET [Recevied_Date]=@Date,[Series]=@Series,[Issuing Office]=@IssuingOffice," +
                        "[FromNo]=@FromNo,[Party]=@Party,[DateOfIssue]=@DateOfIssue,[StateOfIssue]=StateOfIssue,[Narration]=@Narration," +
                        "[ModifiedBy]=@ModifiedBy " +
                        " WHERE Recevied_Id=@id";

                //Query = "UPDATE Recevied_Voucher SET [Recevied_Date]=@Date,[Series]=@Series,[Issuing Office]=@IssuingOffice," +
                //         "[FromNo]=@FromNo,[Party]=@Party,[DateOfIssue]=@DateOfIssue,[StateOfIssue]=StateOfIssue,[Narration]=@Narration," +
                //        "[ModifiedBy]=@ModifiedBy " +
                //        "WHERE Recevied_Id=@id";

                if (_dbHelper.ExecuteNonQuery(Query, paramCollection) > 0)
                {
                    List <ReceviedModel> lstAcct = new List <ReceviedModel>();

                    //UPDATE CREDIT NOTE ACCOUNT -CHILD TABLE UPDATES
                    foreach (ReceviedModel act in objRecevied.ReceviedModel)
                    {
                        if (act.id > 0)
                        {
                            paramCollection = new DBParameterCollection();


                            paramCollection.Add(new DBParameter("@VoucherNo", (act.VoucherNo)));
                            paramCollection.Add(new DBParameter("@Dated", act.Dated));
                            paramCollection.Add(new DBParameter("@amount", act.Amount));

                            paramCollection.Add(new DBParameter("@ModifiedBy", "Admin"));
                            paramCollection.Add(new DBParameter("@ID", (act.id)));
                            //paramCollection.Add(new DBParameter("@CreatedDate", DateTime.Now));

                            Query = "UPDATE Recevied_Amount_Voucher SET [VoucherNo]=@VoucherNo," +
                                    "[Dated]=@Dated,[Amount]=@amount,[ModifiedBy]=@ModifiedBy " +
                                    "WHERE [SNo]=@ID";

                            if (_dbHelper.ExecuteNonQuery(Query, paramCollection) > 0)
                            {
                                isUpdated = true;
                            }
                        }
                        else
                        {
                            paramCollection = new DBParameterCollection();

                            paramCollection.Add(new DBParameter("@ID", (objRecevied.RV_Id)));
                            paramCollection.Add(new DBParameter("@VoucherNo", (act.VoucherNo)));
                            paramCollection.Add(new DBParameter("@Dated", act.Dated));
                            paramCollection.Add(new DBParameter("@amount", act.Amount));

                            paramCollection.Add(new DBParameter("@CreatedBy", "Admin"));
                            //paramCollection.Add(new DBParameter("@CreatedDate", DateTime.Now));


                            Query = "INSERT INTO Recevied_Amount_Voucher ([Recevied_Id],[VoucherNo],[Dated],[Amount]," +
                                    "[CreatedBy]) VALUES " +
                                    "(@ID,@VoucherNo,@Dated,@amount,@CreatedBy)";

                            if (_dbHelper.ExecuteNonQuery(Query, paramCollection) > 0)
                            {
                                isUpdated = true;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                isUpdated = false;
                throw ex;
            }

            return(isUpdated);
        }