private void btnKhales_Click(object sender, EventArgs e) { if (!((txtPlak1.Text != "") && (cmbPlak.Text != "") && (txtPlak2.Text != "") && (txtPlak3.Text != "") && (txtPlak1.Text.Length == 2) && (txtPlak2.Text.Length == 3) && (txtPlak3.Text.Length == 2))) { JMessages.Error(" شماره پلاک را وارد کنید ", ""); txtPlak1.Focus(); return; } bool Flag = true; if (ClassLibrary.JPing.Ping("192.168.3.1")) { JReportUserForm pUser = new JReportUserForm(txtPlak1.Text + cmbPlak.Text + txtPlak2.Text + "-" + txtPlak3.Text); if (pUser.ShowDialog() == DialogResult.OK) { Flag = false; _WeightKhales = pUser._Weight; JEmptyWeight tmp = new JEmptyWeight(); tmp.BascoolNo = Convert.ToInt32(lblBascolNum.Text); tmp.EmptyBascoolNo = pUser._BascolCode; tmp.DateWeight = pUser._Date; tmp.EmptyWeight = pUser._Weight; _Counter = JWeights.GetCounter(); tmp.WeightID = _Counter; if (tmp.WeightID == 0) { JMessages.Error(" خطا در شماره سریال قبض ", ""); return; } if (JMessages.Confirm(" وزن " + tmp.EmptyWeight.ToString(), "") == DialogResult.Yes) { if (tmp.Insert() > 0) { FlagKhales = false; btnSabt_Click(null, null); FlagKhales = true; } else { JMessages.Error(" با موفقیت ثبت نشد ", ""); } _Counter = 0; } } } if (Flag) { JKhalesWeightForm p = new JKhalesWeightForm(); if (p.ShowDialog() == DialogResult.OK) { _WeightKhales = p._Weight; JEmptyWeight tmp = new JEmptyWeight(); tmp.BascoolNo = Convert.ToInt32(lblBascolNum.Text); tmp.EmptyBascoolNo = p._BascolCode; tmp.DateWeight = p._Date; tmp.EmptyWeight = p._Weight; _Counter = JWeights.GetCounter(); tmp.WeightID = _Counter; if (tmp.WeightID == 0) { JMessages.Error(" خطا در شماره سریال قبض ", ""); return; } if (tmp.Insert() > 0) { FlagKhales = false; btnSabt_Click(null, null); FlagKhales = true; } else { JMessages.Error(" با موفقیت ثبت نشد ", ""); } _Counter = 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(); } }
//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(" با موفقیت ثبت نشد ", ""); } }