private void btnDelete_Click(object sender, EventArgs e) { if ((MessageBox.Show("Do u really want to delete this item. ", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning)) == DialogResult.Yes) { CUOM oUOM = Getformdata(); CUOMBO oUOMBO = new CUOMBO(); CResult oresult = new CResult(); if (txtUOMid.Text.Trim() != string.Empty) { oresult = oUOMBO.Delete(oUOM); if (oresult.IsSuccess == true) { if (oresult.Data.ToString() == "0") { MessageBox.Show("Deletion Not Possible", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); LoadUOMType(); ClearFormData(); } else { MessageBox.Show("Deleted Successfully", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); LoadUOMType(); ClearFormData(); } } else { MessageBox.Show("Error" + oresult.ErrMsg + ""); } } } }
private void btnSave_Click(object sender, EventArgs e) { CUOM oUOM = Getformdata(); CUOMBO oUOMBO = new CUOMBO(); CResult oresult = new CResult(); if (validatedata()) { if (txtUOMid.Text.Trim() != string.Empty) { if (DialogResult.OK == MessageBox.Show("Are you wanted to upadte " + txtUOMCode.Text + " ?", "Confirmation!", MessageBoxButtons.OKCancel)) { oresult = oUOMBO.Update(oUOM); } } else { if (!IsUpdateMode) { oresult = oUOMBO.Create(oUOM); } } if (oresult.IsSuccess) { LoadUOMType(); ClearFormData(); } else { MessageBox.Show("Not Saved" + oresult.ErrMsg + ""); } } }
private CItem Getformdata() { CItem oitem = new CItem(); CItemType oItemType = (CItemType)ddlItemType.SelectedItem; CItemGroup oitemgroup = (CItemGroup)ddlGroupNAme.SelectedItem; CUOM oUOM = (CUOM)ddlUOM.SelectedItem; CSize oSize = (CSize)cmbItemSize.SelectedItem; oitem.Item_OID = txthiddenitemid.Text; oitem.Item_Branch = currentBranch.CompBrn_Code; oitem.Item_GroupID = oitemgroup.Catg_OID; oitem.Item_TypeID = oItemType.ITyp_OID; oitem.Item_UOMID = oUOM.UOM_OID; oitem.Item_Code = txtItemCode.Text.Trim(); if (cmbItemSize.SelectedItem != null && txtICode.Text != "") { oitem.Item_ItemName = txtItemName.Text + "-" + txtICode.Text + "-- " + oSize.Size_Name; } if (txtICode.Text != "") { oitem.Item_ItemName = txtItemName.Text + "-" + txtICode.Text; } else { oitem.Item_ItemName = txtItemName.Text; } //oitem.Item_ItemName = txtItemName.Text; oitem.Item_Pprice = float.Parse(txtpprice.Text); oitem.Remarks = txtRemarks.Text; oitem.Item_RQTY = float.Parse(txtRQTY.Text); oitem.Item_Sprice = float.Parse(txtSprice.Text); oitem.Creator = currentUser.User_OID; oitem.CreationDate = DateTime.Now; oitem.UpdateBy = currentUser.User_OID; oitem.UpdateDate = DateTime.Now; oitem.CreationDate = DateTime.Now.Date; if (chkIsActive.Checked) { oitem.IsActive = "Y"; } else { oitem.IsActive = "N"; } oitem.Item_Priority = int.Parse(nupdnItemPriority.Text.Trim()); oitem.ItemImage = this.ItemImage; return(oitem); }
public CResult Update(CUOM oUOM) { oResult = new CResult(); conn = oConnManager.GetConnection(out s_DBError); if (conn != null) { SqlCommand cmd = new SqlCommand(); cmd.Connection = conn; cmd.Transaction = oConnManager.BeginTransaction(); try { cmd.CommandText = "sp_UOM_Update"; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@UOM_OID", oUOM.UOM_OID); cmd.Parameters.AddWithValue("@UOM_Code", oUOM.UOM_Code); cmd.Parameters.AddWithValue("@UOM_Name", oUOM.UOM_Name); cmd.Parameters.AddWithValue("@UOM_Branch", oUOM.UOM_Branch); cmd.Parameters.AddWithValue("@Creator", oUOM.Creator); cmd.Parameters.AddWithValue("@CreationDate", oUOM.CreationDate); cmd.Parameters.AddWithValue("@UpdateBy", oUOM.UpdateBy); cmd.Parameters.AddWithValue("@UpdateDate", oUOM.UpdateDate); cmd.Parameters.AddWithValue("@IsActive", oUOM.IsActive); cmd.Parameters.AddWithValue("@Remarks", oUOM.Remarks); cmd.ExecuteNonQuery(); oConnManager.Commit(); oResult.IsSuccess = true; } catch (SqlException e) { string sRollbackError = oConnManager.Rollback(); oResult.IsSuccess = false; oResult.ErrMsg = sRollbackError.Equals("") ? oConnManager.GetErrorMessage(e) : sRollbackError; } finally { oConnManager.Close(); } } else { oResult.IsSuccess = false; oResult.ErrMsg = s_DBError; } return(oResult); }
private void LLUOMType_SelectedIndexChanged(object sender, EventArgs e) { if (LLUOMType.SelectedIndex != -1) { if (LLUOMType.Items.Count > 0) { CUOM oCUOM = (CUOM)LLUOMType.SelectedItem; txtUOMid.Text = oCUOM.UOM_OID.ToString(); txtUOMCode.Text = oCUOM.UOM_Code; txtUOMName.Text = oCUOM.UOM_Name; txtRemarks.Text = oCUOM.Remarks; FormControlMode(1); } } }
private CUOM Getformdata() { CUOM oUOM = new CUOM(); oUOM.UOM_OID = txtUOMid.Text.Trim(); oUOM.UOM_Branch = currentBranch.CompBrn_Code; oUOM.UOM_Code = txtUOMCode.Text.Trim(); oUOM.UOM_Name = txtUOMName.Text.Trim(); oUOM.Remarks = txtRemarks.Text.Trim(); oUOM.CreationDate = DateTime.Now; oUOM.Creator = currentUser.User_OID; oUOM.UpdateBy = currentUser.User_OID; oUOM.UpdateDate = DateTime.Now; oUOM.IsActive = "Y"; return(oUOM); }
private CUOM GetResultSetToUOM(DataRow dr) { CUOM oUOM = new CUOM(); oUOM.UOM_OID = dr[0].ToString(); oUOM.UOM_Code = dr[1].ToString(); oUOM.UOM_Name = dr[2].ToString(); oUOM.UOM_Branch = dr[3].ToString(); oUOM.Creator = dr[4].ToString(); oUOM.CreationDate = DateTime.Parse(dr[5].ToString()).Date; oUOM.UpdateBy = dr[6].ToString(); oUOM.UpdateDate = DateTime.Parse(dr[7].ToString()).Date; oUOM.IsActive = dr[8].ToString(); oUOM.Remarks = dr[9].ToString(); return(oUOM); }
public CResult Delete(CUOM oUOM) { oResult = new CResult(); conn = oConnManager.GetConnection(out s_DBError); if (conn != null) { SqlCommand cmd = new SqlCommand(); cmd.Connection = conn; cmd.Transaction = oConnManager.BeginTransaction(); try { cmd.CommandText = "sp_UOM_Delete"; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@UOM_OID", oUOM.UOM_OID); cmd.Parameters.Add("@IsSuccess", SqlDbType.Char, 1); cmd.Parameters["@IsSuccess"].Direction = ParameterDirection.ReturnValue; cmd.ExecuteNonQuery(); string st = cmd.Parameters["@IsSuccess"].Value.ToString(); oConnManager.Commit(); oResult.Data = st; oResult.IsSuccess = true; } catch (SqlException e) { string sRollbackError = oConnManager.Rollback(); oResult.IsSuccess = false; oResult.ErrMsg = sRollbackError.Equals("") ? oConnManager.GetErrorMessage(e) : sRollbackError; } finally { oConnManager.Close(); } } else { oResult.IsSuccess = false; oResult.ErrMsg = s_DBError; } return(oResult); }