示例#1
0
        void Save()
        {
            try
            {
                ep1.Clear();

                if (string.IsNullOrEmpty(cmbName.Text.Trim()))
                {
                    ep1.SetError(cmbName, "This field is required.");
                    cmbName.Focus();
                    return;
                }

                if (dgDisplayData.Rows.Count == 0)
                {
                    Datalayer.InformationMessageBox("Record is required.");
                    return;
                }

                int    T005_STOCKINID = 0, T001_ACCOUNTID = 0;
                string T004_DETAILS = "";

                T005_STOCKINID = Datalayer.iT005_STOCKINID;

                int.TryParse(cmbName.SelectedValue.ToString(), out T001_ACCOUNTID);
                T004_DETAILS = txtDetails.Text.Trim();

                if (T005_STOCKINID > 0)
                {
                    int?Iout = 0;
                    MyDa = new MyDabaseDataContext(Properties.Settings.Default.Style_King_Dev);
                    MyDa.USP_VP_DELETE_STOCK_IN(T005_STOCKINID, ref Iout);
                }

                int.TryParse(cmbName.SelectedValue.ToString(), out T001_ACCOUNTID);
                MyDa = new MyDabaseDataContext(Properties.Settings.Default.Style_King_Dev);
                int?T004_ORDERID_out = 0;
                Cursor.Current = Cursors.WaitCursor;
                MyDa           = new MyDabaseDataContext(Properties.Settings.Default.Style_King_Dev);
                MyDa.USP_VP_ADDUPDATE_STOCK_MASTER(T005_STOCKINID, dtpDate.Value, T001_ACCOUNTID, txtDetails.Text.Trim(), Datalayer.iT001_COMPANYID, ref T004_ORDERID_out);
                if (T004_ORDERID_out > 0)
                {
                    T005_STOCKINID = int.Parse(T004_ORDERID_out.Value.ToString());
                    for (int i = 0; i < dgDisplayData.Rows.Count; i++)
                    {
                        if (!string.IsNullOrEmpty(Convert.ToString(dgDisplayData.Rows[i].Cells["TM01_PRODUCTID"].Value)))
                        {
                            int     TM01_PRODUCTID = 0;
                            decimal T005_WEIGHT = 0, T005_QTY = 0;
                            string  T005_UNIT = "", T005_TYPE = "";

                            int.TryParse(Convert.ToString(dgDisplayData.Rows[i].Cells["TM01_PRODUCTID"].Value), out TM01_PRODUCTID);
                            decimal.TryParse(Convert.ToString(dgDisplayData.Rows[i].Cells["T005_QTY"].Value), out T005_QTY);
                            decimal.TryParse(Convert.ToString(dgDisplayData.Rows[i].Cells["T005_WEIGHT"].Value), out T005_WEIGHT);
                            T005_UNIT = Convert.ToString(dgDisplayData.Rows[i].Cells["T005_UNIT"].Value);
                            T005_TYPE = Convert.ToString(dgDisplayData.Rows[i].Cells["T005_TYPE"].Value);

                            int?T008_SALEITEMID_Out = 0;
                            MyDa = new MyDabaseDataContext(Properties.Settings.Default.Style_King_Dev);
                            MyDa.USP_VP_ADDUPDATE_STOCK_IN(0, T005_STOCKINID, TM01_PRODUCTID, T005_QTY, T005_UNIT, T005_TYPE, T005_WEIGHT, Datalayer.iT001_COMPANYID, ref T004_ORDERID_out);
                        }
                    }

                    if (T004_ORDERID_out > 0)
                    {
                        if (Datalayer.iT005_STOCKINID == 0)
                        {
                            Datalayer.InsertMessageBox(sPageName);
                        }
                        else
                        {
                            Datalayer.UpdateMessageBox(sPageName);
                        }

                        ResetData();
                    }
                    else
                    {
                        if (Datalayer.iT005_STOCKINID == 0)
                        {
                            Datalayer.DosenotInsertMessageBox(sPageName);
                        }
                        else
                        {
                            Datalayer.DosenotUpdateMessageBox(sPageName);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Datalayer.WorningMessageBox(ex.Message.ToString(), "Error");
            }
        }