예제 #1
0
        /// <summary>
        /// 更新資料
        /// </summary>
        protected void CustomersLists_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            RedGlovePermission.Model.Customers model = new RedGlovePermission.Model.Customers();
            model.CustomerID = CustomersLists.DataKeys[e.RowIndex].Values[0].ToString();
            model.CustomerAbbrev = ((TextBox)CustomersLists.Rows[e.RowIndex].FindControl("txt_name")).Text.Trim();
            model.Address = ((TextBox)CustomersLists.Rows[e.RowIndex].FindControl("txt_address")).Text.Trim();
            UserSession user = SessionBox.GetUserSession();
            model.Modifier = user.LoginName.ToString();
            model.Modi_Date = DateTime.Now.ToString("yyyyMMdd");

            if (!bll.UpdateCustomer(model))
            {
                ScriptManager.RegisterClientScriptBlock(CustomPanel1, this.GetType(), "MsgBox", "alert('" + ResourceManager.GetString("Pub_Msg_update_false") + "')", true);
            }
            //返回瀏覽狀態
            CustomersLists.EditIndex = -1;
            BindOrder2();
        }
예제 #2
0
        /// <summary>
        /// 新增資料
        /// </summary>
        protected void btn_add_Click(object sender, EventArgs e)
        {
            if (txt_Name.Text.Trim() != "" || txt_ID.Text.Trim() != "")
            {
                RedGlovePermission.Model.Customers model = new RedGlovePermission.Model.Customers();

                model.CustomerID = txt_ID.Text.Trim();
                model.CustomerAbbrev = txt_Name.Text.Trim();
                model.Address = txt_Address.Text.Trim();
                UserSession user = SessionBox.GetUserSession();
                model.Creator = user.LoginName.ToString();
                model.Create_Date = DateTime.Now.ToString("yyyyMMdd");

                if (!bll.Exists(txt_ID.Text.Trim()))
                {
                    if (bll.CreateCustomer(model))
                    {
                        ScriptManager.RegisterClientScriptBlock(CustomPanel1, this.GetType(), "MsgBox", "alert('" + ResourceManager.GetString("Pub_Msg_add_true") + "')", true);
                    }
                    else
                    {
                        ScriptManager.RegisterClientScriptBlock(CustomPanel1, this.GetType(), "MsgBox", "alert('" + ResourceManager.GetString("Pub_Msg_add_false") + "')", true);
                    }
                    txt_ID.Text = "";
                    txt_Name.Text = "";
                    txt_Address.Text = "";
                    BindOrder();
                }
                else
                {
                    ScriptManager.RegisterClientScriptBlock(CustomPanel1, this.GetType(), "MsgBox", "alert('" + ResourceManager.GetString("Pub_Msg_IsCustomer") + "')", true);
                }
            }
        }
예제 #3
0
		/// <summary>
		/// 得到一筆客戶資料
		/// </summary>
		/// <param name="CustomerID">客戶ID</param>
		/// <returns></returns>
		public RedGlovePermission.Model.Customers GetCustomerModel(string CustomerID)
		{
			StringBuilder strSql = new StringBuilder();
			strSql.Append("select top 1 MA001,MA002,MA027 from COPMA ");
			strSql.Append(" where MA001=@CustomerID ");
			SqlParameter[] parameters = {
					new SqlParameter("@CustomerID", SqlDbType.Char,10)};
			parameters[0].Value = CustomerID;

			RedGlovePermission.Model.Customers model = new RedGlovePermission.Model.Customers();
			DataSet ds = SqlServerHelper.Query(strSql.ToString(), parameters);
			if (ds.Tables[0].Rows.Count > 0)
			{
				//if (ds.Tables[0].Rows[0]["MA001"].ToString() != "")
				//{
					model.CustomerID = ds.Tables[0].Rows[0]["MA001"].ToString();
				//}
				model.CustomerAbbrev = ds.Tables[0].Rows[0]["MA002"].ToString();
				model.Address = ds.Tables[0].Rows[0]["MA027"].ToString();
				return model;
			}
			else
			{
				return null;
			}
		}