Пример #1
0
        private int save()
        {
            try
            {
                int j = 1;

                tbl_mjv mjv = new tbl_mjv();

                mjv.mjv_id              = HFmjv.Value;
                mjv.mjv_sono            = string.IsNullOrEmpty(lbl_BPVSNo.Text) ? null : lbl_BPVSNo.Text;
                mjv.mjv_dat             = Convert.ToDateTime(string.IsNullOrEmpty(TBBPVDat.Text) ? null : TBBPVDat.Text);
                mjv.ProductTypeID       = "0";
                mjv.SubHeadCategoriesID = string.IsNullOrEmpty(DDL_AccCde.SelectedValue) ? null : DDL_AccCde.SelectedValue;
                mjv.mjv_Narr            = string.IsNullOrEmpty(TBNarr.Text) ? null : TBNarr.Text;
                mjv.mjv_debtamt         = "0";
                mjv.mjv_crdtamt         = "0";
                mjv.mjv_ttl             = string.IsNullOrEmpty(TBTotal.Text) ? null : TBTotal.Text;
                mjv.Bank_ID             = "";
                mjv.mjv_chqno           = string.IsNullOrEmpty(TBChqNo.Text) ? null : TBChqNo.Text;
                mjv.mjv_chqdat          = string.IsNullOrEmpty(TBChqDat.Text) ? null : TBChqDat.Text;
                mjv.mjv_taxper          = string.IsNullOrEmpty(TBITAX.Text) ? null : TBITAX.Text;
                mjv.mjv_taxamt          = string.IsNullOrEmpty(TBItaxamt.Text) ? null : TBItaxamt.Text;
                mjv.employeeID          = "1";
                mjv.CreatedBy           = Session["user"].ToString();
                mjv.CreatedAt           = DateTime.Today;
                mjv.ISActive            = chk_Act.Checked.ToString();
                mjv.mjv_grdttl          = string.IsNullOrEmpty(TBttlAmt.Text) ? null : TBttlAmt.Text;
                mjv.mjv_Vchtyp          = "BPV";
                mjv.ven_id              = string.IsNullOrEmpty(DDL_Payto.SelectedValue.Trim()) ? null : DDL_Payto.SelectedValue.Trim();

                tbl_mjvManager mjvmanag = new tbl_mjvManager(mjv);
                mjvmanag.Save();

                return(j);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Пример #2
0
        private int save()
        {
            try
            {
                int j = 1;

                tbl_mjv mjv = new tbl_mjv();

                foreach (GridViewRow g1 in GVJV.Rows)
                {
                    string DDL_Par = (g1.FindControl("DDL_Par") as DropDownList).SelectedValue;
                    string TBDbt   = (g1.FindControl("TBDbt") as TextBox).Text;
                    string TBCrd   = (g1.FindControl("TBCrd") as TextBox).Text;
                    string TBnarr  = (g1.FindControl("TBnarr") as TextBox).Text;
                    string JVSNO   = (g1.FindControl("HF_JVSNo") as HiddenField).Value;

                    if (TBDbt == "")
                    {
                        ScriptManager.RegisterStartupScript(this, this.GetType(), "isActive", "Alert();", true);
                        lblalert.Text = "Debit Note Can not be Null";
                    }
                    else if (TBCrd == "")
                    {
                        ScriptManager.RegisterStartupScript(this, this.GetType(), "isActive", "Alert();", true);
                        lblalert.Text = "Credit Note Can not be Null";
                    }
                    else
                    {
                        int        v;
                        int        b;
                        string     str = "select mjv_id, mjv_sono from tbl_mjv order by mjv_id desc";
                        SqlCommand cmd = new SqlCommand(str, con);
                        con.Open();

                        DataTable      dt  = new DataTable();
                        SqlDataAdapter adp = new SqlDataAdapter(cmd);

                        adp.Fill(dt);

                        if (dt.Rows.Count > 0)
                        {
                            SqlDataReader reader = cmd.ExecuteReader();

                            while (reader.Read())
                            {
                                if (string.IsNullOrEmpty(JVSNO))
                                {
                                    v     = Convert.ToInt32(reader["mjv_id"].ToString());
                                    b     = v + 1;
                                    JVSNO = "JV00 " + b.ToString();
                                }
                                //else if (JVSNO != "")
                                //{
                                //    v = Convert.ToInt32(reader["mjv_id"].ToString());
                                //    b = v + 1;
                                //    JVSNO = "JV00 " + b.ToString();

                                //}
                            }
                        }
                        else
                        {
                            JVSNO = "JV00 1";
                        }
                        con.Close();

                        mjv.mjv_id = HFjv.Value;

                        mjv.mjv_sono            = string.IsNullOrEmpty(JVSNO) ? null : JVSNO;
                        mjv.mjv_dat             = Convert.ToDateTime(string.IsNullOrEmpty(TBjvdat.Text) ? null : TBjvdat.Text);
                        mjv.ProductTypeID       = "0";
                        mjv.SubHeadCategoriesID = string.IsNullOrEmpty(DDL_Par) ? null : DDL_Par;
                        mjv.mjv_Narr            = string.IsNullOrEmpty(TBnarr) ? null : TBnarr;
                        mjv.mjv_debtamt         = string.IsNullOrEmpty(TBDbt) ? null : TBDbt;
                        mjv.mjv_crdtamt         = string.IsNullOrEmpty(TBCrd) ? null : TBCrd;
                        mjv.mjv_ttl             = "0.0";
                        mjv.Bank_ID             = "";
                        mjv.mjv_chqno           = "";
                        mjv.mjv_chqdat          = "01/01/1900";
                        mjv.mjv_taxper          = "0.0";
                        mjv.mjv_taxamt          = "0.0";
                        mjv.employeeID          = "1";
                        mjv.CreatedBy           = Session["user"].ToString();
                        mjv.CreatedAt           = DateTime.Today;
                        mjv.ISActive            = "True";
                        mjv.mjv_grdttl          = "0.0";
                        mjv.mjv_Vchtyp          = "JV";
                        mjv.ven_id = "0";


                        tbl_mjvManager mjvmanag = new tbl_mjvManager(mjv);
                        mjvmanag.Save();
                    }
                }
                return(j);
            }
            catch (Exception ex)
            {
                throw;
            }
        }