public ActionResult UpdateSuppliers(M_Suppliers data) { try { data.CreateID = user.EmployeeNo; data.CreateDate = DateTime.Now; data.UpdateID = user.EmployeeNo; data.UpdateDate = DateTime.Now; string Query = ""; Query += "UPDATE [dbo].[M_Suppliers] SET " + " [SupplierName] = '" + data.SupplierName + "'" + " ,[SupplierAddress]= '" + data.Address + "'" + " ,[UpdateID]= '" + data.UpdateID + "'" + " ,[UpdateDate]= '" + data.UpdateDate + "'" + " WHERE [ID] = '" + data.ID + "'"; SqlCommand cmdSql = new SqlCommand(); cmdSql.Connection = conn; cmdSql.CommandTimeout = 0; cmdSql.CommandText = Query; conn.Open(); cmdSql.ExecuteNonQuery(); conn.Close(); return(Json(new { msg = "Success" }, JsonRequestBehavior.AllowGet)); } catch (Exception err) { return(Json(new { msg = err.Message }, JsonRequestBehavior.AllowGet)); } }
private void SetValues(String sm_Supplier) { try { M_SupplierDL objm_SupplierDL = new M_SupplierDL(); M_Suppliers objm_Supplier = new M_Suppliers(); if (sm_Supplier != "") { objm_Supplier.SupID = sm_Supplier; objm_Supplier = objm_SupplierDL.Selectm_Supplier(objm_Supplier); if (objm_Supplier != null) { txt_SupID.Text = objm_Supplier.SupID.ToString(); txt_suppName.Text = objm_Supplier.suppName.ToString(); txt_TP.Text = objm_Supplier.TP.ToString(); txt_Fax.Text = objm_Supplier.Fax.ToString(); txt_Email.Text = objm_Supplier.Email.ToString(); txt_Address1.Text = objm_Supplier.Address1.ToString(); txt_Address2.Text = objm_Supplier.Address2.ToString(); txt_Address3.Text = objm_Supplier.Address3.ToString(); txt_ContactPerson.Text = objm_Supplier.ContactPerson.ToString(); txt_ContactPersonNo.Text = objm_Supplier.ContactPersonNo.ToString(); formMode = 0; } } } catch (Exception ex) { throw ex; } }
public M_Suppliers Selectm_Supplier(M_Suppliers objm_Supplier) { try { strquery = @"SELECT * FROM [M_Suppliers] where [SupID] = '" + objm_Supplier.SupID.Trim() + "'"; DataRow drType = u_DBConnection.ReturnDataRow(strquery); if (drType != null) { objm_Supplier.SupID = drType["SupID"].ToString(); objm_Supplier.suppName = drType["suppName"].ToString(); objm_Supplier.CompCode = drType["CompCode"].ToString(); objm_Supplier.Locacode = drType["Locacode"].ToString(); objm_Supplier.TP = drType["TP"].ToString(); objm_Supplier.Fax = drType["Fax"].ToString(); objm_Supplier.Email = drType["Email"].ToString(); objm_Supplier.Address1 = drType["Address1"].ToString(); objm_Supplier.Address2 = drType["Address2"].ToString(); objm_Supplier.Address3 = drType["Address3"].ToString(); objm_Supplier.ContactPerson = drType["ContactPerson"].ToString(); objm_Supplier.ContactPersonNo = drType["ContactPersonNo"].ToString(); objm_Supplier.CurrentStatus = drType["CurrentStatus"].ToString(); return(objm_Supplier); } return(null); } catch (Exception ex) { throw ex; } }
public static string FindExisitingSupplier(string suppcode) { string str = ""; if (M_SupplierDL.ExistingM_Supplier(suppcode.Trim())) { M_Suppliers cat = new M_Suppliers(); cat.SupID = suppcode.Trim(); M_SupplierDL dl = new M_SupplierDL(); cat = dl.Selectm_Supplier(cat); str = cat.suppName; } else { str = "<Error!!!>"; } return(str); }
public ActionResult CreateSupplier(M_Suppliers data) { try { data.CreateID = user.EmployeeNo; data.CreateDate = DateTime.Now; data.UpdateID = user.EmployeeNo; data.UpdateDate = DateTime.Now; string Query = ""; Query += "INSERT INTO [dbo].[M_Suppliers]" + " ([SupplierName]" + " ,[SupplierAddress]" + " ,[IsDeleted]" + " ,[CreateID]" + " ,[CreateDate]" + " ,[UpdateID]" + " ,[UpdateDate])" + "VALUES" + " ('" + data.SupplierName + "'," + " '" + data.Address + "'," + " '" + 0 + "'," + " '" + data.CreateID + "'," + " '" + data.CreateDate + "'," + " '" + data.UpdateID + "'," + " '" + data.UpdateDate + "')"; SqlCommand cmdSql = new SqlCommand(); cmdSql.Connection = conn; cmdSql.CommandTimeout = 0; cmdSql.CommandText = Query; conn.Open(); cmdSql.ExecuteNonQuery(); conn.Close(); return(Json(new { msg = "Success" }, JsonRequestBehavior.AllowGet)); } catch (Exception err) { return(Json(new { msg = err.Message }, JsonRequestBehavior.AllowGet)); } }
private void FindExisitingSupplier() { try{ if (M_SupplierDL.ExistingM_Supplier(txt_Suplier.Text.Trim())) { M_Suppliers cat = new M_Suppliers(); cat.SupID = txt_Suplier.Text.Trim(); M_SupplierDL dl = new M_SupplierDL(); cat = dl.Selectm_Supplier(cat); txt_Suplier.Text = cat.SupID.Trim(); txt_suppliername.Text = cat.suppName.Trim(); } else { txt_suppliername.Text = "<Supplier Not Exists.>"; } } catch (Exception ex) { LogFile.WriteErrorLog(System.Reflection.MethodBase.GetCurrentMethod().Name, this.Name, ex.Message.ToString(), "Exception"); commonFunctions.SetMDIStatusMessage("Genaral Error", 1); } }
/// <summary> /// Saves a record to the M_Suppliers table. /// </summary> public Boolean SaveM_SupplierSP(M_Suppliers m_Supplier, int formMode) { SqlCommand scom; bool retvalue = false; try { scom = new SqlCommand(); scom.CommandType = CommandType.StoredProcedure; scom.CommandText = "M_SuppliersSave"; scom.Parameters.Add("@SupID", SqlDbType.VarChar, 20).Value = m_Supplier.SupID; scom.Parameters.Add("@suppName", SqlDbType.VarChar, 50).Value = m_Supplier.suppName; scom.Parameters.Add("@CompCode", SqlDbType.VarChar, 20).Value = m_Supplier.CompCode; scom.Parameters.Add("@Locacode", SqlDbType.VarChar, 20).Value = m_Supplier.Locacode; scom.Parameters.Add("@TP", SqlDbType.VarChar, 20).Value = m_Supplier.TP; scom.Parameters.Add("@Fax", SqlDbType.VarChar, 20).Value = m_Supplier.Fax; scom.Parameters.Add("@Email", SqlDbType.VarChar, 50).Value = m_Supplier.Email; scom.Parameters.Add("@Address1", SqlDbType.VarChar, 50).Value = m_Supplier.Address1; scom.Parameters.Add("@Address2", SqlDbType.VarChar, 50).Value = m_Supplier.Address2; scom.Parameters.Add("@Address3", SqlDbType.VarChar, 50).Value = m_Supplier.Address3; scom.Parameters.Add("@ContactPerson", SqlDbType.VarChar, 50).Value = m_Supplier.ContactPerson; scom.Parameters.Add("@ContactPersonNo", SqlDbType.VarChar, 50).Value = m_Supplier.ContactPersonNo; scom.Parameters.Add("@CurrentStatus", SqlDbType.VarChar, 20).Value = m_Supplier.CurrentStatus; scom.Parameters.Add("@InsMode", SqlDbType.Int).Value = formMode; // For insert scom.Parameters.Add("@RtnValue", SqlDbType.Int).Value = 0; u_DBConnection dbcon = new u_DBConnection(); retvalue = dbcon.RunQuery(scom); return(retvalue); } catch (Exception ex) { throw (ex); } }
private void performButtons(xEnums.PerformanceType xenum) { switch (xenum) { case xEnums.PerformanceType.View: if (ActiveControl.Name.Trim() == txt_SupID.Name.Trim()) { int length = Convert.ToInt32(ConfigurationManager.AppSettings["SupplierFieldLength"]); string[] strSearchField = new string[length]; string strSQL = ConfigurationManager.AppSettings["SupplierSQL"].ToString(); for (int i = 0; i < length; i++) { string m; m = i.ToString(); strSearchField[i] = ConfigurationManager.AppSettings["SupplierField" + m + ""].ToString(); } frmU_Search find = new frmU_Search(strSQL, strSearchField, this); find.ShowDialog(this); } break; case xEnums.PerformanceType.New: FunctionButtonStatus(xEnums.PerformanceType.New); //txt_IDX.Text = commonFunctions.GetSerial("A0009"); formMode = 1; txt_SupID.Focus(); errorProvider1.Clear(); break; case xEnums.PerformanceType.Edit: FunctionButtonStatus(xEnums.PerformanceType.Edit); formMode = 3; txt_SupID.Enabled = false; txt_suppName.Focus(); errorProvider1.Clear(); break; case xEnums.PerformanceType.Save: if (txt_suppName.Text.Trim() == "") { errorProvider1.SetError(txt_suppName, "Please enter a supplier name !"); return; } if (txt_SupID.Text.Trim() == "") { errorProvider1.SetError(txt_SupID, "Please enter a supplier code !"); commonFunctions.SetMDIStatusMessage("Please enter a supplier code.", 1); return; } if (formMode == 1) { if (M_SupplierDL.ExistingM_Supplier(txt_SupID.Text.Trim())) { errorProvider1.SetError(txt_SupID, "The supplier code you have entered already exists!"); return; } if (UserDefineMessages.ShowMsg("", UserDefineMessages.Msg_PerfmBtn_Save, commonFunctions.Softwarename.Trim()) == System.Windows.Forms.DialogResult.Yes) { M_Suppliers objm_Supplier = new M_Suppliers(); objm_Supplier.SupID = txt_SupID.Text.Trim(); objm_Supplier.suppName = txt_suppName.Text.Trim(); objm_Supplier.CompCode = commonFunctions.GlobalCompany; objm_Supplier.Locacode = commonFunctions.GlobalLocation; objm_Supplier.TP = txt_TP.Text.Trim(); objm_Supplier.Fax = txt_Fax.Text.Trim(); objm_Supplier.Email = txt_Email.Text.Trim(); objm_Supplier.Address1 = txt_Address1.Text.Trim(); objm_Supplier.Address2 = txt_Address2.Text.Trim(); objm_Supplier.Address3 = txt_Address3.Text.Trim(); objm_Supplier.ContactPerson = txt_ContactPerson.Text.Trim(); objm_Supplier.ContactPersonNo = txt_ContactPersonNo.Text.Trim(); objm_Supplier.CurrentStatus = ""; M_SupplierDL bal = new M_SupplierDL(); bal.SaveM_SupplierSP(objm_Supplier, 1); GetData(); txt_SupID.Enabled = true; FunctionButtonStatus(xEnums.PerformanceType.Save); commonFunctions.SetMDIStatusMessage(UserDefineMessages.Msg_Save_Sucess_string, 2); } } else if (formMode == 3) { if (UserDefineMessages.ShowMsg("", UserDefineMessages.Msg_PerfmBtn_Update, commonFunctions.Softwarename.Trim()) == System.Windows.Forms.DialogResult.Yes) { M_Suppliers objm_Supplier = new M_Suppliers(); objm_Supplier.SupID = txt_SupID.Text.Trim(); objm_Supplier.suppName = txt_suppName.Text.Trim(); objm_Supplier.CompCode = commonFunctions.GlobalCompany; objm_Supplier.Locacode = commonFunctions.GlobalLocation; objm_Supplier.TP = txt_TP.Text.Trim(); objm_Supplier.Fax = txt_Fax.Text.Trim(); objm_Supplier.Email = txt_Email.Text.Trim(); objm_Supplier.Address1 = txt_Address1.Text.Trim(); objm_Supplier.Address2 = txt_Address2.Text.Trim(); objm_Supplier.Address3 = txt_Address3.Text.Trim(); objm_Supplier.ContactPerson = txt_ContactPerson.Text.Trim(); objm_Supplier.ContactPersonNo = txt_ContactPersonNo.Text.Trim(); objm_Supplier.CurrentStatus = ""; M_SupplierDL bal = new M_SupplierDL(); bal.SaveM_SupplierSP(objm_Supplier, 3); GetData(); txt_SupID.Enabled = true; FunctionButtonStatus(xEnums.PerformanceType.Save); commonFunctions.SetMDIStatusMessage(UserDefineMessages.Msg_Update_Sucess_string, 2); } } break; case xEnums.PerformanceType.Cancel: txt_SupID.Enabled = true; FunctionButtonStatus(xEnums.PerformanceType.Default); errorProvider1.Clear(); break; case xEnums.PerformanceType.Print: if (UserDefineMessages.ShowMsg("", UserDefineMessages.Msg_PerfmBtn_Prnt, commonFunctions.Softwarename.Trim()) == System.Windows.Forms.DialogResult.Yes) { string reporttitle = "List of All suppliers".ToUpper(); frm_reportViwer rpt = new frm_reportViwer(); rpt.MdiParent = MDI_SMartAnything.ActiveForm; rpt.FormHeadertext = reporttitle; ParameterField paramField = new ParameterField(); ParameterFields paramFields = new ParameterFields(); paramFields = commonFunctions.AddCrystalParams(reporttitle, commonFunctions.Loginuser.ToUpper()); string str = "SELECT * FROM M_Suppliers"; rpt_m_suppliers rptBank = new rpt_m_suppliers(); rptBank.SetDataSource(commonFunctions.GetDatatable(str)); rpt.RepViewer.ParameterFieldInfo = paramFields; rpt.RepViewer.ReportSource = rptBank; rpt.RepViewer.Refresh(); rpt.Show(); } break; } }