Example #1
0
        public bool Transfer()
        {
            if (!(CreateConnectionServer()))
            {
                JMessages.Error(" ارتباط با بانک اصلی برقرار نمی شود ", "");
                return(false);
            }

            if (!(ClassLibrary.JPing.Ping("192.168.3.1")))
            {
                JMessages.Error(" ارتباط با بانک اصلی برقرار نمی شود ", "");
                return(false);
            }

            ClassLibrary.JDataBase MyDB      = new JDataBase(_Config);
            ClassLibrary.JDataBase CurrentDB = new JDataBase();
            try
            {
                if (CurrentDB.DataBaseName == MyDB.DataBaseName)//"ERP_Sepad")
                {
                    JMessages.Error(" بانک جاری با بانک اصلی یکی است امکان انتقال اطلاعات نیست ", "");
                    return(false);
                }

                string StrPlok = "";
                //int Count = 0;
                //ماشین ها پلاک
                CurrentDB.setQuery(@"select distinct PlokNo,TruckCode from BascolWeights ");
                foreach (DataRow dr4 in CurrentDB.Query_DataTable().Rows) //+ @"' And TruckCode = " + dr4["TruckCode"]
                {
                    StrPlok = @"
declare  @Count int
select @Count=(Select COUNT(*) From BascolPlakTruck  where plokno = N'" + dr4["PlokNo"].ToString().Trim() + @"')
select @Count
if (@Count = 0)
INSERT INTO BascolPlakTruck Values('" + dr4["PlokNo"].ToString().Trim() + "'," + dr4["TruckCode"] + @")";
                    //Count++;
                    //if (Count == 10)
                    //{
                    //    //MyDB.CommandTimeout = 5;
                    //    MyDB.setQuery(StrPlok);
                    //    MyDB.Query_Execute();
                    //    StrPlok = "";
                    //    Count = 0;
                    //}
                    MyDB.CommandTimeout = 2;
                    MyDB.setQuery(StrPlok);
                    MyDB.Query_Execute();
                }


                MyDB.beginTransaction("MainDB");
                CurrentDB.beginTransaction("CurrentDB");

                DataTable _DtAccess = JWeights.GetData();
                JWeight   tmpWeight = new JWeight();
                foreach (DataRow dr in _DtAccess.Rows)
                {
                    tmpWeight.TruckCode    = Convert.ToInt32(dr["TruckCode"]);
                    tmpWeight.UserPostCode = Convert.ToInt32(dr["UserPostCode"]);
                    tmpWeight.PersonCode   = Convert.ToInt32(dr["PersonCode"]);
                    tmpWeight.pay          = Convert.ToInt32(dr["Pay"]);
                    tmpWeight.pay_h        = Convert.ToInt32(dr["pay_h"]);
                    tmpWeight.BascoolCode  = Convert.ToInt32(dr["BascoolCode"]);
                    tmpWeight.WDate        = Convert.ToDateTime(dr["WDate"]);
                    tmpWeight.WTime        = dr["WTime"].ToString();
                    tmpWeight.PlokNo       = dr["PlokNo"].ToString();
                    tmpWeight.Weights      = Convert.ToInt32(dr["Weights"]);
                    tmpWeight.Duty         = Convert.ToDecimal(dr["Duty"]); //(tmpWeight.pay / (100 + _Duty + _Tax)) * _Tax;
                    tmpWeight.Tax          = Convert.ToDecimal(dr["Tax"]);  //(tmpWeight.pay / (100 + _Duty + _Tax)) * _Duty;
                    tmpWeight.hamrahno     = Convert.ToInt32(dr["hamrahNo"]);
                    tmpWeight.ProductCode  = Convert.ToInt32(dr["ProductCode"]);
                    tmpWeight.BascoolID    = Convert.ToInt32(dr["BascoolID"]);
                    tmpWeight.FullW        = Convert.ToInt32(dr["FullW"]);
                    tmpWeight.PrintNo      = Convert.ToInt32(dr["PrintNo"]);
                    //tmpWeight.dele = Convert.ToBoolean(dr["dele"]);
                    //tmpWeight.verify = Convert.ToBoolean(dr["verify"]);

                    if (tmpWeight.Insert(MyDB) > 0)
                    {
                        if (!(tmpWeight.DeleteTransfer(Convert.ToInt32(dr["Code"]), CurrentDB)))
                        {
                            MyDB.Rollback("MainDB");
                            CurrentDB.Rollback("CurrentDB");
                            JMessages.Error(" خطا در همگام سازی ", "");
                            return(false);
                        }
                    }
                    else
                    {
                        MyDB.Rollback("MainDB");
                        CurrentDB.Rollback("CurrentDB");
                        JMessages.Error(" خطا در همگام سازی ", "");
                        return(false);
                    }
                }


                _DtAccess = JEmptyWeight.GetDataTable(-1);
                JEmptyWeight tmpEmptyWeight = new JEmptyWeight();
                foreach (DataRow dr in _DtAccess.Rows)
                {
                    tmpEmptyWeight.Code           = 0;
                    tmpEmptyWeight.BascoolNo      = Convert.ToInt32(dr["BascoolNo"]);
                    tmpEmptyWeight.WeightID       = Convert.ToInt32(dr["WeightID"]);
                    tmpEmptyWeight.EmptyBascoolNo = Convert.ToInt32(dr["EmptyBascoolNo"]);
                    tmpEmptyWeight.WeightSerial   = Convert.ToInt32(dr["WeightSerial"]);
                    tmpEmptyWeight.DateWeight     = Convert.ToDateTime(dr["DateWeight"]);
                    tmpEmptyWeight.EmptyWeight    = Convert.ToInt32(dr["EmptyWeight"]);
                    tmpEmptyWeight.EmptyID        = Convert.ToInt32(dr["EmptyID"]);
                    if (tmpEmptyWeight.Insert(MyDB) > 0)
                    {
                        tmpEmptyWeight.Code = Convert.ToInt32(dr["Code"]);
                        if (!(tmpEmptyWeight.Delete(CurrentDB)))
                        {
                            MyDB.Rollback("MainDB");
                            CurrentDB.Rollback("CurrentDB");
                            JMessages.Error(" خطا در همگام سازی ", "");
                            return(false);
                        }
                    }
                    else
                    {
                        MyDB.Rollback("MainDB");
                        CurrentDB.Rollback("CurrentDB");
                        JMessages.Error(" خطا در همگام سازی ", "");
                        return(false);
                    }
                }

                if (MyDB.Commit())
                {
                    if (CurrentDB.Commit())
                    {
                    }
                    else
                    {
                        MyDB.Rollback("MainDB");
                        CurrentDB.Rollback("CurrentDB");
                        JMessages.Error(" خطا در همگام سازی ", "");
                        return(false);
                    }
                }
                else
                {
                    MyDB.Rollback("MainDB");
                    CurrentDB.Rollback("CurrentDB");
                    JMessages.Error(" خطا در همگام سازی ", "");
                    return(false);
                }

                //  باسکول
                CurrentDB.setQuery(@" delete From Bascols ");
                CurrentDB.Query_Execute();
                //if (CurrentDB.Query_Execute() > 0)
                {
                    foreach (DataRow dr1 in JReport.GetBascols(0, MyDB).Rows)
                    {
                        //MyDB.setQuery(@" Insert Into Bascols Values(" + dr1["Code"] + ",'" + dr1["Location"] + "'," + dr1["Capacity"] + ",'" + dr1["BDesc"] + "'," + dr1["Active"]+ ")");
                        CurrentDB.setQuery(@" Insert Into Bascols Values(" + dr1["Code"] + ",NULL," + dr1["Capacity"] + ",'" + dr1["BDesc"] + "',NULL)");
                        if (CurrentDB.Query_Execute() <= 0)
                        {
                            return(false);
                        }
                    }
                }

                //  محصول
                CurrentDB.setQuery(@" delete From Subdefine Where bCode=901");
                CurrentDB.Query_Execute();
                //if (CurrentDB.Query_Execute() > 0)
                {
                    foreach (DataRow dr3 in JProductss.GetDataTable(MyDB).Rows)
                    {
                        CurrentDB.setQuery(@" Insert Into Subdefine Values(" + dr3["Code"] + ",901,'" + dr3["Name"] + "',0,NULL)");
                        if (CurrentDB.Query_Execute() <= 0)
                        {
                            return(false);
                        }
                    }
                }

                //  ماشینها
                CurrentDB.setQuery(@" delete From BascolTruck ");
                CurrentDB.Query_Execute();
                //if (CurrentDB.Query_Execute() > 0)
                {
                    foreach (DataRow dr2 in JTruck.GetDataTransfer(MyDB).Rows)
                    {
                        CurrentDB.setQuery(@"INSERT INTO BascolTruck Values(" + dr2["Code"] + ",'" + dr2["Name"] + "'," + dr2["Price"] + ",'" + Convert.ToDateTime(dr2["StartDate"]).ToShortDateString() + "' ,'" + Convert.ToDateTime(dr2["EndDate"]).ToShortDateString() + "','" + dr2["Shortcut"].ToString().Trim() + "')");
                        if (CurrentDB.Query_Execute() <= 0)
                        {
                            return(false);
                        }
                    }
                }

                //ماشین ها پلاک
                CurrentDB.setQuery(@" Select Max(Code) From BascolPlakTruck ");
                int MaxCode = Convert.ToInt32(CurrentDB.Query_ExecutSacler());
                //if (CurrentDB.Query_Execute() > 0)
                //{
                MyDB.setQuery(@"select Code,PlokNo,TruckCode from BascolPlakTruck Where Code > " + MaxCode);
                foreach (DataRow dr4 in MyDB.Query_DataTable().Rows)
                {
                    CurrentDB.setQuery("INSERT INTO BascolPlakTruck Values( " + dr4["Code"] + ",'" + dr4["PlokNo"] + "'," + dr4["TruckCode"] + ")");
                    if (CurrentDB.Query_Execute() <= 0)
                    {
                        return(false);
                    }
                }
                CurrentDB.setQuery(@"delete from BascolPlakTruck Where Code in
(select B.Code from BascolPlakTruck A inner join BascolPlakTruck B on A.PlokNo=B.PlokNo And A.Code > B.Code)");
                CurrentDB.Query_Execute();
                //return false;
                //}

                //  لیست سیاه
                //CurrentDB.setQuery(@" delete From BascoolBlackList ");
                //if (CurrentDB.Query_Execute() > 0)
                //{
                //    MyDB.setQuery("select * from BascoolBlackList ");
                //    foreach (DataRow dr5 in MyDB.Query_DataTable().Rows)
                //    {
                //        CurrentDB.setQuery(@" Insert Into BascoolBlackList Values(" + dr5["Code"] + ")");
                //        if (CurrentDB.Query_Execute() <= 0)
                //            return false;
                //    }
                //}

                //
                //CurrentDB.setQuery(@" delete From BascolTaxFormula ");
                //if (CurrentDB.Query_Execute() > 0)
                //{
                //    MyDB.setQuery(@"Select top 1 Duty From BascolTaxFormula ");
                //    _Duty = Convert.ToDecimal(MyDB.Query_ExecutSacler());
                //    MyDB.setQuery(@"Select top 1 Tax From BascolTaxFormula ");
                //    _Tax = Convert.ToDecimal(MyDB.Query_ExecutSacler());
                //    CurrentDB.setQuery(@"INSERT INTO BascolTaxFormula values(" + _Duty + "," + _Tax + ")");
                //    if (CurrentDB.Query_Execute() <= 0)
                //        return false;
                //}
                return(true);
            }
            catch (Exception ex)
            {
                JSystem.Except.AddException(ex);
                MyDB.Rollback("MainDB");
                CurrentDB.Rollback("CurrentDB");
                return(false);
            }
            finally
            {
                MyDB.Dispose();
                CurrentDB.Dispose();
            }
        }
Example #2
0
        //dele,verify,pay,Duty,Tax,
        private void btnPrint2_Click(object sender, EventArgs e)
        {
            if (jJanusGrid1.DataSource == null)
            {
                JMessages.Error(" ابتدا دکمه جستجو را بزنید ", "");
                return;
            }
            if (jJanusGrid1.SelectedRow == null)
            {
                JMessages.Error(" لطفا سطری را انتخاب کنید ", "");
                return;
            }
            _Code = Convert.ToInt32(jJanusGrid1.SelectedRow.Row["Code"].ToString());
            DataTable dt    = JWeights.GetDataTableAll(_Code, true);
            string    State = "این برگه المثنی" + " قبض شماره " + dt.Rows[0]["BascoolID"].ToString() + " مورخ " + dt.Rows[0]["WDate"].ToString() + "ساعت" + dt.Rows[0]["WTime"].ToString().Trim() + "می باشد";

            JWeight tmpWeight = new JWeight();

            tmpWeight.TruckCode    = Convert.ToInt32(dt.Rows[0]["TruckCode"].ToString());
            tmpWeight.UserPostCode = JMainFrame.CurrentPostCode;
            tmpWeight.PersonCode   = JMainFrame.CurrentPersonCode;
            tmpWeight.pay          = Convert.ToInt32(dt.Rows[0]["pay"].ToString());
            tmpWeight.pay_h        = Convert.ToInt32(dt.Rows[0]["pay"].ToString());
            tmpWeight.BascoolCode  = Convert.ToInt32(dt.Rows[0]["BascoolCode"].ToString());
            tmpWeight.PlokNo       = dt.Rows[0]["P1"].ToString() + dt.Rows[0]["P2"].ToString() + dt.Rows[0]["P3"].ToString() + dt.Rows[0]["P4"].ToString();
            tmpWeight.Weights      = Convert.ToInt32(dt.Rows[0]["Weights"].ToString());
            //tmpWeight.Duty = Convert.ToDecimal(dt.Rows[0]["Duty"].ToString());
            //tmpWeight.Tax = Convert.ToDecimal(dt.Rows[0]["Tax"].ToString());
            JTransferData tmpT = new JTransferData();

            tmpT.GetTaxDuty();
            tmpWeight.Duty = (tmpWeight.pay / (100 + tmpT._Duty + tmpT._Tax)) * tmpT._Duty;
            tmpWeight.Tax  = (tmpWeight.pay / (100 + tmpT._Duty + tmpT._Tax)) * tmpT._Tax;

            tmpWeight.hamrahno    = Convert.ToInt32(dt.Rows[0]["hamrahno"].ToString());
            tmpWeight.ProductCode = Convert.ToInt32(dt.Rows[0]["ProductCode"].ToString());
            tmpWeight.PrintNo     = 2;
            string Min = "";

            if (DateTime.Now.Minute.ToString().Length == 1)
            {
                Min = "0" + DateTime.Now.Minute.ToString();
            }
            else
            {
                Min = DateTime.Now.Minute.ToString();
            }
            string Hour = "";

            if (DateTime.Now.Hour.ToString().Length == 1)
            {
                Hour = "0" + DateTime.Now.Hour.ToString();
            }
            else
            {
                Hour = DateTime.Now.Hour.ToString();
            }
            tmpWeight.WTime = Hour + ":" + Min;

            tmpWeight.BascoolID = JWeights.GetCounter();
            tmpWeight.WDate     = DateTime.Now;

            JTransferData tmpJTransferData = new JTransferData();
            JDataBase     dbMain           = tmpJTransferData.CreateConMainServer(false);

            if (tmpWeight.Insert() > 0)//dbMain
            {
                dt = JWeights.GetDataTableAll(tmpWeight.Code, false);
            }
            dt.Columns.Add("State");
            dt.Columns.Add("StateHamrah");
            dt.Rows[0]["State"] = State;
            if (Convert.ToInt32(dt.Rows[0]["HamrahNO"]) != 0)
            {
                dt.Rows[0]["StateHamrah"] = dt.Rows[0]["HamrahNO"] + "    تعداد همراه  ";
            }
            else
            {
                dt.Rows[0]["StateHamrah"] = "";
            }
            if (dt != null)
            {
                //JDynamicReportForm DRF = new JDynamicReportForm(JReportDesignCodes.Bascool.GetHashCode());
                JDynamicReports DRF = new JDynamicReports(JReportDesignCodes.BillGoods.GetHashCode());
                DRF.Add(dt);
                //DRF.ShowDialog();
                DRF.Print("چاپ قبض", false, false);
            }

            try
            {
                dbMain.setQuery("Update BascolWeights set PrintNo=PrintNo+1 Where Code=" + _Code);
                dbMain.Query_Execute();
            }
            catch (Exception ex)
            {
                JSystem.Except.AddException(ex);
            }
            finally
            {
                dbMain.Dispose();
            }
        }
Example #3
0
        public bool TransferAccess()
        {
            try
            {
                if (CreateConnectionServer())
                {
                    JMessages.Error(" ارتباط با بانک اصلی برقرار نمی شود ", "");
                    return(false);
                }
                ClassLibrary.JDataBase MyDB = new JDataBase(_Config);
                //ClassLibrary.JOLeDbDataBase MyDB = new ClassLibrary.JOLeDbDataBase();
                JWeights tmpWeights = new JWeights();
                //MyDB.setQuery(@"Select * From Weight");
                DataTable _DtAccess = tmpWeights.GetDataTable();
                DataTable _DtSQL;
                foreach (DataRow dr in _DtAccess.Rows)
                {
                    JWeight tmpWeight = new JWeight();
                    tmpWeight.TruckCode    = Convert.ToInt32(dr["TruckNo"]);
                    tmpWeight.UserPostCode = Convert.ToInt32(dr["UserPostCode"]);
                    tmpWeight.PersonCode   = Convert.ToInt32(dr["UserNo"]);
                    tmpWeight.pay          = Convert.ToInt32(dr["Pay"]);
                    tmpWeight.pay_h        = Convert.ToInt32(dr["pay_h"]);
                    tmpWeight.BascoolCode  = Convert.ToInt32(dr["BascoolCode"]);
                    tmpWeight.WDate        = Convert.ToDateTime(dr["WDate"]);
                    tmpWeight.WTime        = dr["WTime"].ToString();
                    tmpWeight.PlokNo       = dr["PlokNo"].ToString();
                    tmpWeight.Weights      = Convert.ToInt32(dr["Weights"]);
                    tmpWeight.Duty         = Convert.ToDecimal(dr["Duty"]); //(tmpWeight.pay / (100 + _Duty + _Tax)) * _Tax;
                    tmpWeight.Tax          = Convert.ToDecimal(dr["Tax"]);  //(tmpWeight.pay / (100 + _Duty + _Tax)) * _Duty;
                    tmpWeight.hamrahno     = Convert.ToInt32(dr["hamrahNo"]);
                    tmpWeight.ProductCode  = Convert.ToInt32(dr["ProductNo"]);

                    if (tmpWeight.Insert(MyDB) > 0)
                    {
                        tmpWeight.Delete(tmpWeight.Code);
                        MyDB.setQuery(@"Delete From Weight Where id = " + dr["Code"]);
                        if (MyDB.Query_Execute() <= 0)
                        {
                            JMessages.Error(" خطا در همگام سازی ", "");
                            return(false);
                        }
                    }
                }

                MyDB.setQuery(@"SELECT ID, WeightSerial, BascoolNo, DateWeight, EmptyWeight, WeightID  FROM EmptyTruck");
                _DtAccess = MyDB.Query_DataTable();
                foreach (DataRow dr in _DtAccess.Rows)
                {
                    JEmptyWeight tmpEmptyWeight = new JEmptyWeight();
                    tmpEmptyWeight.BascoolNo      = Convert.ToInt32(dr["BascoolNo"]);
                    tmpEmptyWeight.WeightID       = Convert.ToInt32(dr["WeightID"]);
                    tmpEmptyWeight.EmptyBascoolNo = Convert.ToInt32(dr["EmptyBascoolNo"]);
                    tmpEmptyWeight.WeightSerial   = Convert.ToInt32(dr["WeightSerial"]);
                    tmpEmptyWeight.DateWeight     = Convert.ToDateTime(dr["DateWeight"]);
                    tmpEmptyWeight.EmptyWeight    = Convert.ToInt32(dr["EmptyWeight"]);
                    tmpEmptyWeight.EmptyID        = Convert.ToInt32(dr["EmptyID"]);

                    if (tmpEmptyWeight.Insert() > 0)
                    {
                        MyDB.setQuery(@"Delete From Weight Where id = " + dr["Code"]);
                        if (MyDB.Query_Execute() <= 0)
                        {
                            JMessages.Error(" خطا در همگام سازی ", "");
                            return(false);
                        }
                    }
                }
                //  باسکول
                MyDB.setQuery(@" delete From Bascools ");
                if (MyDB.Query_Execute() > 0)
                {
                    foreach (DataRow dr1 in JReport.GetBascols(0).Rows)
                    {
                        MyDB.setQuery(@" Insert Into Bascools (" + dr1["Code"] + ",'" + dr1["Location"] + "'," + dr1["Capacity"] + ",'" + dr1["BDesc"] + "'," + dr1["Active"]);
                        if (MyDB.Query_Execute() <= 0)
                        {
                            return(false);
                        }
                    }
                }

                //  محصول
                MyDB.setQuery(@" delete From Product ");
                if (MyDB.Query_Execute() > 0)
                {
                    foreach (DataRow dr3 in JProductss.GetDataTable().Rows)
                    {
                        MyDB.setQuery(@" Insert Into Product (" + dr3["Code"] + ",'" + dr3["Name"] + "'");
                        if (MyDB.Query_Execute() <= 0)
                        {
                            return(false);
                        }
                    }
                }

                //  ماشینها
                MyDB.setQuery(@" delete From Truck ");
                if (MyDB.Query_Execute() > 0)
                {
                    foreach (DataRow dr2 in JTruck.GetDataTable(0).Rows)
                    {
                        MyDB.setQuery(@"INSERT INTO Truck(TruckId,Name,wp)values(" + dr2["Code"] + ",'" + dr2["Name"] + "'," + dr2["Price"] + ")");
                        if (MyDB.Query_Execute() <= 0)
                        {
                            return(false);
                        }
                    }
                }

                //
                MyDB.setQuery(@" delete From TaxFormula ");
                if (MyDB.Query_Execute() > 0)
                {
                    //GetTaxDuty();
                    //MyDB.setQuery(@"INSERT INTO (Duty, Tax) values(" + _Duty + "," + _Tax + ")");
                    if (MyDB.Query_Execute() <= 0)
                    {
                        return(false);
                    }
                }
                return(true);
            }
            catch (Exception ex)
            {
                JSystem.Except.AddException(ex);
                return(false);
            }
        }
Example #4
0
        //public bool InsertAccess()
        //{
        //    ClassLibrary.JOLeDbDataBase MyDB = new ClassLibrary.JOLeDbDataBase();
        //    try
        //    {
        //        string txtplok = txtPlak1.Text + cmbPlak.Text + txtPlak2.Text + "-" + txtPlak3.Text;
        //        MyDB.setQuery(@"INSERT INTO Weight (WDate,WTime,Plokno,UserNo,ProductNo,Weights,TruckNo,PrintNo,hamrahno,pay_h, BascoolNo,UserPostCode,Pay) VALUES ('" +
        //    txtDate.Date + "','" + txtTime.Text + "','" + txtplok + "'," + JMainFrame.CurrentPersonCode + "," + cmbProduct.SelectedValue.ToString() + "," +
        //    lblWeight.Text + "," + lsTrucks.SelectedValue.ToString() + ",1," + txtHamrah.Text + "," + (Convert.ToInt32(txtPay.Text)+ Convert.ToInt32(lblBedehkari.Text)).ToString()
        //    + "," + lblBascolNum.Text + "," + JMainFrame.CurrentPostCode + "," + _Price+ ")");

        //        if (MyDB.Query_Execute() > 0)
        //        {
        //            Print();
        //            btnClear_Click(null, null);
        //            JMessages.Error(" با موفقیت ثبت شد ", "");
        //            return true;
        //        }
        //        else
        //        {
        //            JMessages.Error(" با موفقیت ثبت نشد ", "");
        //            return false;
        //        }
        //    }
        //    finally
        //    {
        //        MyDB.Dispose();
        //    }
        //}

        private void btnSabt_Click(object sender, EventArgs e)
        {
            try
            {
                #region CheckData
                if (Convert.ToInt32(cmbTruck.SelectedValue) == -1)
                {
                    JMessages.Error(" ماشین را وارد کنید ", "");
                    cmbTruck.Focus();
                    return;
                }
                if (txtPay.Text == "")
                {
                    JMessages.Error(" قیمت را وارد کنید ", "");
                    txtPay.Focus();
                    return;
                }
                if ((txtPlak1.Text == "") || (txtPlak1.Text.Length < 2))
                {
                    JMessages.Error(" شماره پلاک را وارد کنید ", "");
                    txtPlak1.Focus();
                    return;
                }
                if ((txtPlak2.Text == "") || (txtPlak2.Text.Length < 3))
                {
                    JMessages.Error(" شماره پلاک را وارد کنید ", "");
                    txtPlak2.Focus();
                    return;
                }
                if ((txtPlak3.Text == "") || (txtPlak3.Text.Length < 2))
                {
                    JMessages.Error(" شماره پلاک را وارد کنید ", "");
                    txtPlak2.Focus();
                    return;
                }
                if (cmbPlak.Text == "")
                {
                    JMessages.Error(" شماره پلاک را وارد کنید ", "");
                    txtPlak2.Focus();
                    return;
                }
                if (lblBascolNum.Text == "0")
                {
                    JMessages.Error(" شماره باسکول وجود ندارد در قسمت تنظیمات شماره باسکول را تنظیم کنید ", "");
                    return;
                }
                if (lblWeight.Text == "0")
                {
                    JMessages.Error(" توزینی روی باسکول وجود ندارد ", "");
                    return;
                }
                #endregion

                string  txtplok   = txtPlak1.Text + cmbPlak.Text + txtPlak2.Text + "-" + txtPlak3.Text;
                JWeight tmpWeight = new JWeight();
                //tmpWeight.TruckCode = Convert.ToInt32(lsTrucks.SelectedValue.ToString());
                tmpWeight.TruckCode    = Convert.ToInt32(cmbTruck.SelectedValue.ToString());
                tmpWeight.UserPostCode = JMainFrame.CurrentPostCode;
                tmpWeight.PersonCode   = JMainFrame.CurrentPersonCode;
                tmpWeight.pay          = _Price;//Convert.ToInt32(txtPay.Text);
                tmpWeight.pay_h        = Convert.ToInt32(txtPay.Text);
                tmpWeight.BascoolCode  = Convert.ToInt32(lblBascolNum.Text);
                //tmpWeight.WDate = txtDate.Date;
                tmpWeight.WDate   = DateTime.Now;
                tmpWeight.WTime   = lblTime.Text;
                tmpWeight.PlokNo  = txtplok;
                tmpWeight.Weights = Convert.ToInt32(lblWeight.Text);
                tmpWeight.Duty    = (tmpWeight.pay / (100 + _Duty + _Tax)) * _Duty;
                tmpWeight.Tax     = (tmpWeight.pay / (100 + _Duty + _Tax)) * _Tax;
                if (txtHamrah.Text == "")
                {
                    txtHamrah.Text = "0";
                }
                tmpWeight.hamrahno    = Convert.ToInt32(txtHamrah.Text);
                tmpWeight.ProductCode = Convert.ToInt32(cmbProduct.SelectedValue.ToString());
                tmpWeight.PrintNo     = 1;
                if (_Counter == 0)
                {
                    tmpWeight.BascoolID = JWeights.GetCounter();
                }
                else
                {
                    tmpWeight.BascoolID = _Counter;
                }
                if (tmpWeight.BascoolID == 0)
                {
                    JMessages.Error(" خطا در شماره سریال قبض ", "");
                    return;
                }
                if ((JSystem.Nodes.DataTable.Rows.Count > 0) && ((JSystem.Nodes.DataTable.Rows.Count % 5) == 0) && (FlagKhales))
                {
                    Transfer(false);
                    lblWeight.Visible = false;
                    lblWeight.Visible = true;
                }
                _Code = tmpWeight.Insert();
                if (_Code > 0)
                {
                    //InsertAccess();
                    txtPlak1.Text = "";
                    Print();
                    //if (JSystem.Nodes.DefaultView.Rows.Count > 20)
                    //    btnHamgam_Click(null,null);
                    Clear();
                    txtPlak1.Focus();
                }
                else
                {
                    JMessages.Error(" با موفقیت ثبت نشد ", "");
                }
            }
            catch (Exception ex)
            {
                JSystem.Except.AddException(ex);
                JMessages.Error(" با موفقیت ثبت نشد ", "");
            }
        }