protected void btnUSave_Click(object sender, EventArgs e) { if (hfPopupUpdate.Value == "0") { if (txtSupplierLevel.Text == "") { txtSupplierLevel.Text = "0"; } string sql_insert = "Insert into [Supplier] (SupplierName, SupplierAddress, SupplierAccount, SupplierLevel, SupplierPhone, SupplierEmail, DateAdded) values (N'" + txtSupplierName.Text.Trim() + "', N'" + txtSupplierAddress.Text.Trim() + "', N'" + txtSupplierAccount.Text.Trim() + "', " + txtSupplierLevel.Text + ", '" + txtSupplierPhone.Text + "', N'" + txtSupplierEmail.Text + "', GETDATE())"; if (objDb.DbCommand(sql_insert) == "0") { ScriptManager.RegisterStartupScript(this, GetType(), "Popup", "alertMessage('Thành công!','success','Thêm mới thành công!');", true); } LoadSupplier(); } else { int _idUpdate = int.Parse(hfPopupUpdate.Value); string sql_update = "Update [Supplier] set SupplierName = N'" + txtSupplierName.Text.Trim() + "', SupplierAddress = N'" + txtSupplierAddress.Text.Trim() + "', SupplierAccount = N'" + txtSupplierAccount.Text.Trim() + "', SupplierLevel = " + txtSupplierLevel.Text + ", SupplierPhone = '" + txtSupplierPhone.Text + "', SupplierEmail = '" + txtSupplierEmail.Text + "', DateUpdated = GETDATE() where SupplierID = " + _idUpdate; if (objDb.DbCommand(sql_update) == "0") { ScriptManager.RegisterStartupScript(this, GetType(), "Popup", "alertMessage('Thành công!','success','Cập nhật thành công!');", true); } LoadSupplier(); } }
private void UpdateProfile(string userID) { int isActive, isAdminstrator; if (txtUserActived.Checked) { isActive = 1; } else { isActive = 0; } if (txtAdministrator.Checked) { isAdminstrator = 1; } else { isAdminstrator = 0; } string sql = "Update [User] set UserFirstName = N'" + txtFirstName.Text.Trim() + "', UserLastName = N'" + txtLastName.Text.Trim() + "', UserAddress = N'" + txtUserAddress.Text.Trim() + "', UserActived = " + isActive + ", IsAdministration = " + isAdminstrator + ", UserIP = '" + txtUserIP.Text.Trim() + "', UserPhone = '" + txtUserPhone.Text.Trim() + "' where UserID =" + userID; if (objDb.DbCommand(sql) == "0") { System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.Append(@"<script type='text/javascript'>"); sb.Append("alert('Update profile is successful!');"); sb.Append(@"</script>"); ScriptManager.RegisterClientScriptBlock(this, GetType(), "", sb.ToString(), false); } }
protected void btnUSave_Click(object sender, EventArgs e) { if (hfPopupUpdate.Value == "0") { if (txtCategoryPosition.Text == "") { txtCategoryPosition.Text = "0"; } if (txtQuanlity.Text == "") { txtQuanlity.Text = "0"; } string sql_insert = "Insert into [Category] (CategoryName, CategoryPosition, ProductsQuanlity, Dateadded) values (N'" + txtCategoryName.Text.Trim() + "', " + txtCategoryPosition.Text + ", " + txtQuanlity.Text + ", GETDATE())"; if (objDb.DbCommand(sql_insert) == "0") { ScriptManager.RegisterStartupScript(this, GetType(), "Popup", "alertMessage('Thành công!','success','Thêm mới thành công!');", true); } LoadCategory(); } else { int _idUpdate = int.Parse(hfPopupUpdate.Value); string sql_update = "Update [Category] set CategoryName = N'" + txtCategoryName.Text.Trim() + "', CategoryPosition = " + txtCategoryPosition.Text + ", ProductsQuanlity = " + txtQuanlity.Text + ", DateUpdated = GETDATE() where CategoryID = " + _idUpdate; if (objDb.DbCommand(sql_update) == "0") { ScriptManager.RegisterStartupScript(this, GetType(), "Popup", "alertMessage('Thành công!','success','Cập nhật thành công!');", true); } LoadCategory(); } }
protected void btnUSave_Click(object sender, EventArgs e) { if (hfPopupUpdate.Value == "0") { string sku = ""; sku = objUtil.ConvertToUnsign(txtProductName.Text.Trim()) + "_" + objUtil.ConvertToUnsign(drlProductCategory.SelectedItem.Text) + "_" + DateTime.Now.Second.ToString() + DateTime.Now.Year.ToString(); string sql_insert = "Insert into [Product] (ProductSKU, ProductName, ProductPrice, ProductShortDesc, ProductLongDesc, ProductCategoryID, DateAdded) values ('" + sku + "', N'" + txtProductName.Text.Trim() + "', " + txtProductPrice.Text + ", N'" + txtProductShortDesc.Text.Trim() + "', N'" + txtProductLongDesc.Text.Trim() + "', " + drlProductCategory.SelectedValue + ", GETDATE())"; if (objDb.DbCommand(sql_insert) == "0") { ScriptManager.RegisterStartupScript(this, GetType(), "Popup", "alertMessage('Thành công!','success','Thêm mới sản phẩm thành công!');", true); } } else { int _idUpdate = int.Parse(hfPopupUpdate.Value); string sql_update = "Update [Product] set ProductName = N'" + txtProductName.Text.Trim() + "', ProductPrice = " + txtProductPrice.Text + ", ProductShortDesc = N'" + txtProductShortDesc.Text.Trim() + "', ProductLongDesc = N'" + txtProductLongDesc.Text.Trim() + "', ProductCategoryID = " + drlProductCategory.SelectedValue.ToString() + ", ProductUpdateDate = GETDATE() where ProductID = " + _idUpdate; if (objDb.DbCommand(sql_update) == "0") { ScriptManager.RegisterStartupScript(this, GetType(), "Popup", "alertMessage('Thành công!','success','Cập nhật sản phẩm thành công!');", true); } } LoadProducts(); }