private void dgSearch_CellContentClick(object sender, DataGridViewCellEventArgs e) { try { if (e.ColumnIndex == 11) { int selectId = int.Parse(dgSearch.CurrentRow.Cells[10].Value.ToString()); using (var context = new StimulsoftEntities()) { var select = context.ReportService.Where(c => c.Id == selectId).FirstOrDefault(); if (select.Ready == "1") { select.Ready = "0"; context.SaveChanges(); dgSearch.CurrentCell.Value = true; return; } if (select.Ready == "0") { select.Ready = "1"; context.SaveChanges(); dgSearch.CurrentCell.Value = false; return; } } } } catch (Exception ex) { MessageBox.Show("عوض کردن وضعیت آماده جستجو" + "\n" + ex.Message); } }
private void btnSave_Click(object sender, EventArgs e) { using (var context = new StimulsoftEntities()) { if (context.Unit.Count() > 0) { bool existUnit = context.Unit.Where(c => c.Name == txtUnitName.Text).Any(); if (existUnit) { MessageBox.Show("این واحد وجود دارد", "واحد", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { Unit newUnit = new Unit(); newUnit.Name = txtUnitName.Text; context.Unit.Add(newUnit); context.SaveChanges(); MessageBox.Show("واحد ثبت شد", "ثبت", MessageBoxButtons.OK, MessageBoxIcon.Information); txtUnitName.Text = ""; txtUnitName.Focus(); } } else { Unit newUnit = new Unit(); newUnit.Name = txtUnitName.Text; context.Unit.Add(newUnit); context.SaveChanges(); MessageBox.Show("واحد ثبت شد", "ثبت", MessageBoxButtons.OK, MessageBoxIcon.Information); txtUnitName.Text = ""; txtUnitName.Focus(); } } }
private void btnSaveProdoct_Click(object sender, EventArgs e) { if (majhool[0] == "editProdoct") // baraye edit kardane mahsool { using (var context = new StimulsoftEntities()) { Int32 id = Int32.Parse(majhool[1]); var selectProdoct = context.AnbarProdoct.Where(c => c.Id == id).FirstOrDefault(); if (selectProdoct == null) { MessageBox.Show("این نام محصول تکراری است", "ثبت", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { selectProdoct.Name = txtNameProdoct.Text; selectProdoct.Code = int.Parse(txtCodeProdoct.Text); selectProdoct.IdUnit = comUnit.SelectedIndex; selectProdoct.Description = txtDetails.Text; selectProdoct.Barcode = txtBarcode.Text; selectProdoct.RfID = txtRFID.Text; context.SaveChanges(); MessageBox.Show("ویرایش انجام شد", "ویرایش", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); FormAnbar frmAnbar = new FormAnbar(); frmAnbar.Refresh_dgProdoct(); } } } }
private void btnDeleteMotorOil_Click(object sender, EventArgs e) { lblError.Text = ""; try { using (var context = new StimulsoftEntities()) { int x = Convert.ToInt16(dgShow.CurrentRow.Cells[4].Value.ToString()); ServicesPrice del = context.ServicesPrice.Where(current => current.Id == x).FirstOrDefault(); context.ServicesPrice.Remove(del); context.SaveChanges(); lblError.ForeColor = Color.Green; lblError.Text = "خدمت با موفقیت حذف شد"; context.Dispose(); Refresh_Price(); comGroup.Text = ""; txtServiceName.Text = ""; txtKindKala.Text = ""; txtServisPrice.Text = ""; } } catch (Exception) { lblError.ForeColor = Color.Red; lblError.Text = "عملیات حذف با مشکل مواجه شد"; } }
//************** private void btnEdit_Click(object sender, EventArgs e) { try { lblError.Text = ""; if (txtPhone.TextLength > 11 || txtPhone.TextLength < 11) { lblError.ForeColor = Color.Red; lblError.Text = "شماره موبایل 11 عدد نیست"; //txtPhone.Text = "0"; return; } using (var context = new StimulsoftEntities()) { var findPhone = context.User.Where(c => c.Phone == txtPhone.Text).ToList(); if (phoneNumber != txtPhone.Text || phoneNumber != txtPhone.Text) { if (findPhone != null) { lblError.Text = "این شماره تماس قبلا ثبت شده"; return; } } var editUser = context.User.Where(c => c.Eshterak == txtEshterak.Text).FirstOrDefault(); editUser.Name = txtName.Text; editUser.Phone = txtPhone.Text; //editUser.Eshterak = txtEshterak.Text; if (txtEnter.Text == " / /") { editUser.Date = 0; } else { editUser.Date = Int64.Parse(txtEnter.Text.Replace("/", "")); } editUser.Email = txtEmail.Text; editUser.Address = txtAddress.Text; editUser.PostiCode = txtPostiCode.Text; if (txtBirthDay.Text == " / /") { editUser.BirthDayDate = 0; } else { editUser.BirthDayDate = Int64.Parse(txtBirthDay.Text.Replace("/", "")); } //************ context.SaveChanges(); lblError.ForeColor = Color.Green; lblError.Text = "اطلاعات با موفقیت ثبت شد"; } } catch (Exception) { lblError.Text = ""; } }
private void btnSaveUser_Click(object sender, EventArgs e) { try { using (var context = new StimulsoftEntities()) { Colleague colleague = new Colleague(); colleague.Name = txtName.Text; colleague.Phone = txtPhone.Text; colleague.Tel = txtTel.Text; //---- string selectDay = dateEnter.Text.Replace("/", ""); selectDay = selectDay.Replace(" ", ""); if (selectDay == "") { colleague.DateEnter = 0; } else { colleague.DateEnter = int.Parse(selectDay); } selectDay = dateBirthDay.Text.Replace("/", ""); selectDay = selectDay.Replace(" ", ""); if (selectDay == "") { colleague.DateBirthDay = 0; } else { colleague.DateBirthDay = int.Parse(selectDay); } if (radFemale.Enabled) { colleague.Sex = "زن"; } else { colleague.Sex = "مرد"; } colleague.Address = txtAddress.Text; colleague.CardNumber = mtxtCardNumber.Text; colleague.AccountNumber = txtAccountNumber.Text; colleague.Description = txtDescription.Text; colleague.Email = txtEmail.Text; colleague.Eshterak = txtEshterak.Text; context.Colleague.Add(colleague); context.SaveChanges(); } } catch (Exception) { MessageBox.Show("مشکل در ثبت همکار", "همکار", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void Add_Prodoct() { AnbarProdoct newprodoct = new AnbarProdoct(); newprodoct.Name = txtNameProdoct.Text; newprodoct.Code = long.Parse(txtCodeProdoct.Text); newprodoct.IdUnit = comUnit.SelectedIndex; newprodoct.Description = txtDetails.Text; newprodoct.Barcode = txtBarcode.Text; newprodoct.RfID = txtRFID.Text; context.AnbarProdoct.Add(newprodoct); context.SaveChanges(); MessageBox.Show("محصول ثبت شد", "ثبت", MessageBoxButtons.OK, MessageBoxIcon.Information); txtNameProdoct.Text = ""; txtCodeProdoct.Text = ""; txtDetails.Text = ""; txtBarcode.Text = ""; txtRFID.Text = ""; txtNameProdoct.Focus(); }
private void btnSave_Click(object sender, EventArgs e) { lblError.Text = ""; try { using (var context = new StimulsoftEntities()) { var name = context.ServicesPrice.Where(current => current.ServisKind == comGroup.Text && current.ServiceKala == txtKindKala.Text && current.ServiseName == txtServiceName.Text).ToList(); if (name.Count == 0) { ServicesPrice pri = new ServicesPrice(); pri.ServisKind = comGroup.Text; pri.ServiseName = txtServiceName.Text; pri.ServiceKala = txtKindKala.Text; //if (txtServisPrice.Text != "") pri.ServicePrice = Convert.ToInt64(txtServisPrice.Text); // else //pri.ServicePrice1 = 0; context.SaveChanges(); context.ServicesPrice.Add(pri); context.SaveChanges(); lblError.ForeColor = Color.Green; lblError.Text = "اطلاعات خدمت ثبت شد"; Refresh_Price(); } else { lblError.ForeColor = Color.Red; lblError.Text = " خدمت با این مقادیر وجود دارد"; } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void btnUpdatePriceOilMotor_Click(object sender, EventArgs e) { lblError.Text = ""; try { using (var context = new StimulsoftEntities()) { Int64 price = Convert.ToInt64(txtServisPrice.Text); var service = context.ServicesPrice.Where(current => current.ServisKind == comGroup.Text && current.ServiceKala == txtKindKala.Text && current.ServiseName == txtServiceName.Text && current.ServicePrice == price).ToList(); if (service.Count == 0) { int x = Convert.ToInt16(dgShow.CurrentRow.Cells[4].Value.ToString()); var update = context.ServicesPrice.Where(current => current.Id == x).FirstOrDefault(); if (update != null) { update.ServisKind = comGroup.Text; update.ServiceKala = txtKindKala.Text; update.ServiseName = txtServiceName.Text; if (txtServisPrice.Text != "") { update.ServicePrice = Convert.ToInt64(txtServisPrice.Text); } else { update.ServicePrice = 0; } context.SaveChanges(); context.Dispose(); } lblError.ForeColor = Color.Green; lblError.Text = "ویرایش با موفقبت اتجام شد"; Refresh_Price(); } else { lblError.ForeColor = Color.Red; lblError.Text = " خدمت با این مقادیر وجود دارد"; } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void btnDelStore_Click(object sender, EventArgs e) { StimulsoftEntities context = new StimulsoftEntities(); if (dgStore.Rows.Count > 0 && dgStore.CurrentRow != null) { int id = int.Parse(dgStore.CurrentRow.Cells[0].Value.ToString()); DialogResult result = MessageBox.Show("آیا از حذف فروشگاه مطئن هستید؟", "حذف", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { var selectStore = context.Store.Where(c => c.Id == id).FirstOrDefault(); context.Store.Remove(selectStore); context.SaveChanges(); Refresh_dgStore(); } } }
private void btnDelete_Click(object sender, EventArgs e) { lblError.Text = ""; try { using (var context = new StimulsoftEntities()) { var delete = context.Manage.Where(current => current.UserName.Contains(txtUsername.Text)).ToList(); if (delete.Count == 0) { var result = MessageBox.Show("کاربر مورد نظر پیدا نشد،آیا همه موارد را میخواهید؟", "مدیریت", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result == DialogResult.Yes) { dgManage.DataSource = context.Manage.ToList(); Refresh_Manage(); } else { txtUsername.Focus(); } } if (delete.Count == 1) { Manage del = context.Manage.Where(current => current.UserName == txtUsername.Text).FirstOrDefault(); context.Manage.Remove(del); context.SaveChanges(); lblError.ForeColor = Color.Green; lblError.Text = "کاربر با موفقیت حذف شد"; context.Dispose(); Refresh_Manage(); txtUsername.Text = ""; txtPassword.Text = ""; txtConfrimPasword.Text = ""; } if (delete.Count > 1) { dgManage.DataSource = delete.ToList(); } } } catch (Exception) { lblError.ForeColor = Color.Red; lblError.Text = "عملیات حذف با مشکل مواجه شد"; } }
}// update kardane maghadire dgStore public void Add_Parent_Prodoct() // ezafe kardane faktore jadid be jadvale AnbarParent va tolide code rahgirie jadid { try { StimulsoftEntities context = new StimulsoftEntities(); AnbarParent parent = new AnbarParent(); parent.Case = comCase.SelectedIndex; parent.Date = int.Parse(Date.Text.Replace("/", "")); parent.Description = txtDetails.Text; context.AnbarParent.Add(parent); context.SaveChanges(); //------ groupProdoct.Enabled = true; dgProdoct.Focus(); txtCodeProdoct.ForeColor = Color.Black; //----- if (context.Anbar.Count() > 0) { var listCodeRahgiri = context.Anbar.ToList(); long endCodeRahgiri = Int32.Parse(listCodeRahgiri.LastOrDefault().CodeRahgiri.ToString()); endCodeRahgiri++; lblCodeRahgiri.Text = endCodeRahgiri.ToString(); } else if (context.Anbar.Count() == 0) { lblCodeRahgiri.Text = "1"; } context.Dispose(); { StimulsoftEntities context1 = new StimulsoftEntities(); if (context1.AnbarParent.Count() > 0) { var selectIdParent = context1.AnbarParent.ToList(); idParent = selectIdParent.LastOrDefault().Id; } } //idParent = selectIdParent; } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void log_Load(object sender, EventArgs e) { try { using (var context = new StimulsoftEntities()) { //var name = context.Settings.FirstOrDefault(); //if (name == null) // label3.Text = " مدریت خشکشویی "; //else //{ // string titel = " مدریت خشکشویی " + name.CommercialName; // label3.Text = titel; //} bool exsist = context.Manage.Where(c => c.UserName == "admin").Any(); if (exsist == false) { Manage manage = new Manage(); manage.UserName = "******"; manage.Password = "******"; manage.Access = "0"; manage.NewService = "0"; manage.Tools = "0"; manage.Search = "0"; manage.Sms = "0"; manage.Report = "0"; manage.Backup = "0"; manage.Setting = "0"; context.Manage.Add(manage); context.SaveChanges(); } } } catch (Exception) { Application.Exit(); } }
private async void btnAccept_Click(object sender, EventArgs e) { try { if (adad.ToString() == txtAccept.Text) { FormMain1 frmMain = new FormMain1(); using (var context = new StimulsoftEntities()) { var save = context.Setting.FirstOrDefault(); //---------------bekhatere inke table faghat 1 record dashte bashad if gozashtam if (save != null) { try { Ping ping = new Ping(); PingReply pingStatus = ping.Send("www.papiloo.ir"); if (pingStatus.Status == IPStatus.Success) { var ser = context.Reg.FirstOrDefault(); string application = "خشکشویی", managename = txtManageName.Text, serial = HDDSerialL.SerialNumber(), cammersialname = txtName.Text, state = "true", trans = "", phone = txtMobile.Text, tel = txtTel.Text, email = txtEmail.Text, address = txtAdress.Text, Reagent = txtReagent.Text; Data_Importer Data = new Data_Importer(); string data = await Data.GET("https://www.papiloo.ir/Papiloo/App/Register/Insert.php", application, managename, serial, cammersialname, state, trans, phone, tel, email, address, Reagent); //MessageBox.Show("نسخه آزمایشی در دسترس شماست", " ثبت نام", MessageBoxButtons.OK, MessageBoxIcon.Information); //------------tarif etelaate foroshgah va modir save.CommercialName = txtName.Text; save.ManageName = txtManageName.Text; save.Mobile = txtMobile.Text; save.Tel = txtTel.Text; save.Email = txtEmail.Text; save.Address = txtAdress.Text; //-----------tanzimate sms save.GroupSms = "true"; save.WelcomeSms = "true"; save.AcceptSms = "true"; save.ReadySms = "true"; save.DeliverySms = "true"; save.BirthDaySms = "true"; save.InviteClubeSms = "true"; //----------------- context.SaveChanges(); //---- frmMain.toolCreateServiceToolStripMenuItem.Enabled = true; frmMain.toolToolsToolStripMenuItem.Enabled = true; frmMain.toolSearchToolStripMenuItem.Enabled = true; frmMain.toolSmsToolStripMenuItem.Enabled = true; frmMain.toolAnbar.Enabled = true; frmMain.toolReports.Enabled = true; frmMain.toolBackupRestore.Enabled = true; frmMain.toolManageToolStripMenuItem1.Visible = true; frmMain.toolManagePriceToolStripMenuItem.Visible = true; frmMain.tooSettingApplication.Visible = true; frmMain.toolManageToolStripMenuItem.Enabled = true; frmMain.strlblVersion.Text = "نسخه آزمایشی"; //------ // BARAYE INKE IdPaye ra begirad MessageBox.Show("نسخه آزمایشی در دسترس شماست", " ثبت نام", MessageBoxButtons.OK, MessageBoxIcon.Information); string strReq; string strData; Stream dataStream; StreamReader reader; WebRequest request; WebResponse response; strReq = "http://www.papiloo.ir/Papiloo/App/Register/Select_Serial.php?Serial=" + HDDSerialL.SerialNumber(); request = WebRequest.Create(strReq); response = request.GetResponse(); dataStream = response.GetResponseStream(); reader = new StreamReader(dataStream); strData = reader.ReadToEnd(); //MessageBox.Show(strData); reader.Close(); response.Close(); //-------- var addReg = context.Reg.FirstOrDefault(); string [] a = strData.Split('*'); addReg.IdPaye = a[0]; context.SaveChanges(); Application.Restart(); //this.Close(); } else { MessageBox.Show("اینترنت وصل نیست", "اینترنت", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } catch (Exception) { MessageBox.Show("اینترنت قطع است", "ارتباط", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } else { try { //---------add www for https Ping ping = new Ping(); PingReply pingStatus = ping.Send("www.papiloo.ir"); if (pingStatus.Status == IPStatus.Success) { var ser = context.Reg.FirstOrDefault(); string application = "خشکشویی", managename = txtManageName.Text, serial = IDGenerator.GetCPUId(), cammersialname = txtName.Text, state = "false", trans = "", phone = txtMobile.Text, tel = txtTel.Text, email = txtEmail.Text, address = txtAdress.Text, Reagent = txtReagent.Text; Data_Importer Data = new Data_Importer(); string data = await Data.GET("https://www.papiloo.ir/Papiloo/App/Register/Insert.php", application, managename, serial, cammersialname, state, trans, phone, tel, email, address, Reagent); //MessageBox.Show("نسخه آزمایشی در دسترس شماست", " ثبت نام", MessageBoxButtons.OK, MessageBoxIcon.Information); //-------- Setting setting = new Setting(); //------------tarif etelaate foroshgah va modir setting.CommercialName = txtName.Text; setting.ManageName = txtManageName.Text; setting.Mobile = txtMobile.Text; setting.Tel = txtTel.Text; setting.Email = txtEmail.Text; setting.Address = txtAdress.Text; //-----------tanzimate sms setting.GroupSms = "true"; setting.WelcomeSms = "true"; setting.AcceptSms = "true"; setting.ReadySms = "true"; setting.DeliverySms = "true"; setting.BirthDaySms = "true"; setting.InviteClubeSms = "true"; //----------------- context.Setting.Add(setting); context.SaveChanges(); frmMain.strlblVersion.Text = "نسخه آزمایشی"; MessageBox.Show("نسخه آزمایشی در دسترس شماست", " ثبت نام", MessageBoxButtons.OK, MessageBoxIcon.Information); Application.Restart(); //this.Close(); } else { MessageBox.Show("اینترنت وصل نیست", "اینترنت", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } catch (Exception) { MessageBox.Show("اینترنت قطع است", "ارتباط", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } } } else { MessageBox.Show("کد تایید اشتباه است", "اخطار", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void dgSearch_CellContentClick(object sender, DataGridViewCellEventArgs e) { try { if (e.ColumnIndex == 12) { int selectId = int.Parse(dgSearch.CurrentRow.Cells[10].Value.ToString()); using (var context = new StimulsoftEntities()) { var select = context.ReportService.Where(c => c.Id == selectId).FirstOrDefault(); if (select.Ready == "1") { select.Ready = "0"; context.SaveChanges(); dgSearch.CurrentCell.Value = true; return; } if (select.Ready == "0") { select.Ready = "1"; context.SaveChanges(); dgSearch.CurrentCell.Value = false; return; } } } if (e.ColumnIndex == 13) { int selectId = int.Parse(dgSearch.CurrentRow.Cells[10].Value.ToString()); using (var context = new StimulsoftEntities()) { var del = context.ReportService.Where(c => c.Id == selectId).FirstOrDefault(); context.ReportService.Remove(del); context.SaveChanges(); var user = context.ReportService.Where(c => c.CodeRahgiri == label1.Text).ToList(); dgSearch.DataSource = user; Design_GrideView_Report_Service(); //-----mohasebe mojadade hazine service bad az hazfe 1 khedmat var editPrice = context.Service.Where(c => c.CodeRahgiri == label1.Text).FirstOrDefault(); long sum = 0; long valueAdded = 0; if (dgSearch.RowCount > 0) { for (int i = 0; i < dgSearch.RowCount; i++) { sum = sum + long.Parse(dgSearch.Rows[i].Cells[7].Value.ToString()); valueAdded = valueAdded + long.Parse(dgSearch.Rows[i].Cells[11].Value.ToString()); } editPrice.SumServices = sum; editPrice.ValueAdded = valueAdded; context.SaveChanges(); return; } if (dgSearch.RowCount == 0)//hame khedmatha hazf shavad in khedmat az list serviceha hazf shsvad { context.Service.Remove(editPrice); context.SaveChanges(); } } } } catch (Exception ex) { MessageBox.Show("عوض کردن وضعیت آماده ویرایش" + "\n" + ex.Message); } }
private void btnUpdate_Click(object sender, EventArgs e) { lblError.Text = ""; try { using (var context = new StimulsoftEntities()) { if (txtUsername.Text != "") { var admin = context.Manage.Where(current => current.UserName == txtUsername.Text).ToList(); if (admin.Count == 1) { var update = context.Manage.Where(current => current.UserName == txtUsername.Text).FirstOrDefault(); if (update != null) { update.UserName = txtUsername.Text; if (txtPassword.Text == txtConfrimPasword.Text) { update.Password = txtPassword.Text; update.Access = comAccess.SelectedIndex.ToString(); //--- if (chxNewService.Checked) { update.NewService = "1"; } else { update.NewService = "0"; } //--- if (chxTools.Checked) { update.Tools = "1"; } else { update.Tools = "0"; } //--- if (chxSearch.Checked) { update.Search = "1"; } else { update.Search = "0"; } //--- if (chxSms.Checked) { update.Sms = "1"; } else { update.Sms = "0"; } //--- if (chxReport.Checked) { update.Report = "1"; } else { update.Report = "0"; } //--- if (chxBackup.Checked) { update.Backup = "1"; } else { update.Backup = "0"; } //--- if (chxSetting.Checked) { update.Setting = "1"; } else { update.Setting = "0"; } context.SaveChanges(); context.Dispose(); lblError.ForeColor = Color.Green; lblError.Text = "ویرایش با موفقبت اتجام شد"; Refresh_Manage(); } else { lblError.ForeColor = Color.Red; lblError.Text = "کلمه عبورها با هم یکسان نیست"; } } else { lblError.ForeColor = Color.Red; lblError.Text = "نام کاربر را وارد کنید"; } } else { lblError.ForeColor = Color.Red; lblError.Text = "کاربری با این نام وجود ندارد"; } } else { lblError.ForeColor = Color.Red; lblError.Text = "نام کاربر را وارد کنید"; } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void btnSave_Click(object sender, EventArgs e) { lblError.Text = ""; try { if (txtPassword.Text == txtConfrimPasword.Text) { using (var context = new StimulsoftEntities()) { var exist = context.Manage.Where(ex => ex.UserName == txtUsername.Text).ToList(); if (exist.Count == 0) { Manage admin = new Manage(); admin.UserName = txtUsername.Text; admin.Password = txtPassword.Text; admin.Access = comAccess.SelectedIndex.ToString(); //--- if (chxNewService.Checked) { admin.NewService = "1"; } else { admin.NewService = "0"; } //--- if (chxTools.Checked) { admin.Tools = "1"; } else { admin.Tools = "0"; } //--- if (chxSearch.Checked) { admin.Search = "1"; } else { admin.Search = "0"; } //--- if (chxSms.Checked) { admin.Sms = "1"; } else { admin.Sms = "0"; } //--- if (chxReport.Checked) { admin.Report = "1"; } else { admin.Report = "0"; } //--- if (chxBackup.Checked) { admin.Backup = "1"; } else { admin.Backup = "0"; } //--- if (chxSetting.Checked) { admin.Setting = "1"; } else { admin.Setting = "0"; } context.Manage.Add(admin); context.SaveChanges(); lblError.ForeColor = Color.Green; lblError.Text = "مدیر جدید ثبت شد"; Refresh_Manage(); } else { lblError.ForeColor = Color.Red; lblError.Text = "این نام کاربری وجود دارد"; } } } else { lblError.ForeColor = Color.Red; lblError.Text = "کلمه عبورها با هم یکسان نیست"; } } catch (Exception ex) { lblError.ForeColor = Color.Red; lblError.Text = ex.Message; } }
private void btnSave_Click(object sender, EventArgs e) { //MessageBox.Show("آقا /خانم " + txtName.Text + " به خشکشویی باران خوش آمدید\nکد اشتراک شما " + txtEshterak.Text, "هشدار", MessageBoxButtons.OK, MessageBoxIcon.Warning); //MessageBox.Show("آقا /خانم " + txtName + " به خشکشویی باران خوش آمدید.کد اشتراک شما " + txtEshterak.Text); try { if (txtEshterak.Text == "") { MessageBox.Show("شماره اشتراک خالی است", "هشدار", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { using (var context = new StimulsoftEntities()) { bool isContact = context.User.Where(check => check.Eshterak == txtEshterak.Text).Any(); if (isContact) { //MessageBox.Show("کاربری بااین شماره اشتراک وجود دارد", "اشتراک", MessageBoxButtons.OK, MessageBoxIcon.Warning); lblError.ForeColor = Color.Red; lblError.Text = "کاربری بااین شماره اشتراک وجود دارد"; txtEshterak.Focus(); } else { if (txtPhone.Text == "") { txtPhone.Text = "0"; } User user = new User { Name = txtName.Text, Phone = txtPhone.Text, Eshterak = txtEshterak.Text, //Date = int.Parse(DateEnter.Text.Replace("/", "")), Email = txtEmail.Text, //************ }; context.User.Add(user); context.SaveChanges(); lblError.ForeColor = Color.Green; lblError.Text = "اطلاعات با موفقیت ثیت شد"; } } } } catch (Exception ex) { MessageBox.Show(ex.Message); } //-----ersal sms try { // PARSGREEN.API_SendSMS.SendSMS send = new PARSGREEN.API_SendSMS.SendSMS(); PARSGREEN.API.SMS.Send.SendSMS send = new PARSGREEN.API.SMS.Send.SendSMS(); int successCount = 0; int restStatus; string[] restr = null; restStatus = send.SendGroupSMS("8B0AA695-E750-4CB3-AF3E-98F9D03F06AC", "10001000300076", new string[] { txtPhone.Text }, "آقا /خانم " + txtName.Text + " به خشکشویی باران خوش آمدید\nکد اشتراک شما " + txtEshterak.Text, false, string.Empty, ref successCount, ref restr); //MessageBox.Show("تعداد پیام ها: " + restStatus.ToString() + "\r" + "تحویل داده شده: " + successCount); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
//private string Count_Prodoct(string codeProdoct , int count) // bargardandane tedad mojoodi anbar //{ // StimulsoftEntities context = new StimulsoftEntities(); //} private void btnSaveAllProdoct_Click(object sender, EventArgs e) { try { if (dgAnbar.RowCount == 0) { return; } StimulsoftEntities context = new StimulsoftEntities(); for (int i = 0; i < dgAnbar.RowCount; i++) { Anbar newAnbar = new Anbar(); newAnbar.IdProdoct = Int32.Parse(dgAnbar.Rows[i].Cells[0].Value.ToString()); newAnbar.Name = dgAnbar.Rows[i].Cells[1].Value.ToString(); newAnbar.IdParent = idParent; // newAnbar.Count // baraye jame maghadir in kala newAnbar.Price = int.Parse(txtPriceProdoct.Text.Replace(",", "")); newAnbar.Description = dgAnbar.Rows[i].Cells[5].Value.ToString(); newAnbar.DateExpierd = int.Parse(dgAnbar.Rows[i].Cells[6].Value.ToString().Replace("/", "")); newAnbar.CodeRahgiri = int.Parse(lblCodeRahgiri.Text); newAnbar.IdStore = idStore; //long countGrid = switch (comCase.SelectedIndex) { case 0: // reside khard (mojoodi ezafe shavad) case 3: // resid tolid (mojoodi ezafe shavad) case 4: // bargasgt kala foroosh (mojoodi ezafe shavad) case 7: // bargasht kala amani (mojoodi ezafe shavad) { newAnbar.Positiv = Int32.Parse(dgAnbar.Rows[i].Cells[3].Value.ToString()); newAnbar.Negativ = 0; break; } case 1: // havale foroosh (mojoodi kam shavad) case 2: // havale masraf (mojoodi kam shavad) case 5: // bargashte kala masraf (mojoodi kam shavad) case 6: // havale anbar amani (mojoodi kam shavad) { newAnbar.Positiv = 0; newAnbar.Negativ = Int32.Parse(dgAnbar.Rows[i].Cells[3].Value.ToString()); break; } } //------ context.Anbar.Add(newAnbar); } context.SaveChanges(); MessageBox.Show("محصولات ثبت شد", "ثبت", MessageBoxButtons.OK, MessageBoxIcon.Information); dgAnbar.Rows.Clear(); btnSaveAllProdoct.Enabled = false; groupProdoct.Enabled = false; //} } catch (Exception ex) { MessageBox.Show(ex.Message); //throw; } }
private void btnDelete_Click(object sender, EventArgs e) { if (lbldel.Text == "1") { try { lblError.Text = ""; try { using (var context = new StimulsoftEntities()) { var delete = context.User.Where(current => current.Eshterak == txtEshterak.Text).ToList(); if (delete.Count == 0) { var result = MessageBox.Show("شماره اشتراک مورد نظر پیدا نشد،آیا همه موارد را میخواهید؟", "شماره اشتراک", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result == DialogResult.Yes) { dgDelete.DataSource = context.User.ToList(); Refresh_dgUser(); } else { txtEshterak.Focus(); } } if (delete.Count == 1) { User del = context.User.Where(current => current.Eshterak == txtEshterak.Text).FirstOrDefault(); context.User.Remove(del); context.SaveChanges(); lblError.ForeColor = Color.Green; lblError.Text = " اشتراک با موفقیت حذف شد"; context.Dispose(); Refresh_dgUser(); txtEshterak.Text = ""; txtEshterak.Focus(); } if (delete.Count > 1) { dgDelete.DataSource = delete.ToList(); } } } catch (Exception) { lblError.ForeColor = Color.Red; lblError.Text = "عملیات حذف با مشکل مواجه شد"; txtEshterak.Focus(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } } //----------------------- //----------------------- if (lbldel.Text == "2") { try { lblError.Text = ""; using (var context = new StimulsoftEntities()) { string id = dgDelete.CurrentRow.Cells[14].Value.ToString(); var delete = context.Service.Where(current => current.IdService.ToString() == id).ToList(); if (delete.Count == 0) { var result = MessageBox.Show("شماره سرویس مورد نظر پیدا نشد،آیا همه موارد را میخواهید؟", "شماره سرویس", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result == DialogResult.Yes) { dgDelete.DataSource = context.Service.ToList(); Refresh_dgService(); } else { txtEshterak.Focus(); } } if (delete.Count == 1) { var del = context.Service.Where(current => current.IdService.ToString() == id).FirstOrDefault(); context.Service.Remove(del); context.SaveChanges(); lblError.ForeColor = Color.Green; lblError.Text = " سرویس با موفقیت حذف شد"; Refresh_dgService(); context.Dispose(); txtEshterak.Text = ""; txtEshterak.Focus(); } if (delete.Count > 1) { dgDelete.DataSource = delete.ToList(); } } } catch (Exception) { lblError.ForeColor = Color.Red; lblError.Text = "عملیات حذف با مشکل مواجه شد"; txtEshterak.Focus(); } } }
private void dgSearch_CellContentClick(object sender, DataGridViewCellEventArgs e) { try { if (e.ColumnIndex == 7) { try { //***********baraye check kardane ertebat //HttpWebRequest reqCheack = (HttpWebRequest)WebRequest.Create("http://login.parsgreen.com/UrlService/sendSMS.ashx?from="); //System.Net.WebResponse respCheack = reqCheack.GetResponse(); //*********** //Ping ping = new Ping(); //PingReply pingStatus = ping.Send("google.com"); var sign = context.Setting.FirstOrDefault(); if (sign.Signature == null || sign.Signature == "" || sign.NumberSms == null || sign.NumberSms == "") { MessageBox.Show("از قسمت تنظیمات امضا دیجیتال و شماره پیامک را ثبت کنید", "امضا دیجیتال ", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } //if (pingStatus.Status == IPStatus.Success) //{ string pattern = "http://login.parsgreen.com/UrlService/sendSMS.ashx?from=" + sign.NumberSms + "&to=" + dgSearch.CurrentRow.Cells[1].Value.ToString() + "&text=" + dgSearch.CurrentRow.Cells[2].Value.ToString() + "&signature=" + sign.Signature; //MessageBox.Show(pattern); System.IO.Stream st = null; System.IO.StreamReader sr = null; HttpWebRequest req = (HttpWebRequest)WebRequest.Create(pattern); Encoding encode = System.Text.Encoding.UTF8; System.Net.WebResponse resp = req.GetResponse(); st = resp.GetResponseStream(); sr = new System.IO.StreamReader(st, Encoding.UTF8); string result = sr.ReadToEnd().Substring(12, 1); if (result == "0") { string id = dgSearch.CurrentRow.Cells[6].Value.ToString(); var del = context.ErsalNashode.Where(c => c.Id.ToString() == id).FirstOrDefault(); context.ErsalNashode.Remove(del); context.SaveChanges(); Refresh_dgSearch(); } sr.Close(); resp.Close(); //} } catch (Exception) { MessageBox.Show("اینترنت وصل نیست", "اینترنت", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } if (e.ColumnIndex == 8) { string id = dgSearch.CurrentRow.Cells[6].Value.ToString(); var del = context.ErsalNashode.Where(c => c.Id.ToString() == id).FirstOrDefault(); context.ErsalNashode.Remove(del); context.SaveChanges(); Refresh_dgSearch(); return; } } catch (Exception) { //MessageBox.Show("اینترنت وصل نیست 2"+"\n"+ex.Message, "اینترنت", MessageBoxButtons.OK, MessageBoxIcon.Warning); //MessageBox.Show("ارسال نشده2" + "\n" + ex.Message); } }
//************** private void btnEdit_Click(object sender, EventArgs e) { try { lblError.Text = ""; if (txtPhone.TextLength > 11 || txtPhone.TextLength < 11) { lblError.ForeColor = Color.Red; lblError.Text = "شماره موبایل 11 عدد نیست"; return; } using (var context = new StimulsoftEntities()) { var editService = context.Service.Where(c => c.CodeRahgiri == txtCodeRahgiri.Text).FirstOrDefault(); editService.Name = txtName.Text; editService.DateService = int.Parse(txtDateService.Text.Replace("/", "")); editService.Mobile = txtPhone.Text; if (txtBeiane.Text != "") { editService.Bestankar = Int64.Parse(txtBeiane.Text.Replace(",", "")); } else { editService.Bestankar = 0; } if (txtTakhfif.Text != "") { editService.Takhfif = Int64.Parse(txtTakhfif.Text.Replace(",", "")); } else { editService.Takhfif = 0; } if (txtTotalSum.Text != "") { editService.SumServices = Int64.Parse(txtTotalSum.Text.Replace(",", "")); } else { editService.SumServices = 0; } editService.NumberService = txtSomeService.Value.ToString(); editService.ReadyDate = Int64.Parse(txtReadyDate.Text.Replace("/", "")); editService.SendReadySms = Int64.Parse(txtReadySms.Value.ToString()); editService.Description = txtDescription.Text; if (txtPardakhti.Text != "") { editService.Pardakhti = Int64.Parse(txtPardakhti.Text.Replace(",", "")); } else { editService.Pardakhti = 0; } //************ context.SaveChanges(); lblError.ForeColor = Color.Green; lblError.Text = "اطلاعات با ویرایش شد"; } } catch (Exception ex) { MessageBox.Show(ex.Message); lblError.Text = ""; } }