Ejemplo n.º 1
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (DialogResult.OK == MessageBox.Show("Are you want to delete " + txtCode.Text + " ?", "Confirmation!", MessageBoxButtons.OKCancel))
            {
                CCompanyBranch   oCompanyBranch   = GetFormData();
                CCompanyBranchBO oCompanyBranchBO = new CCompanyBranchBO();
                CResult          oResult          = new CResult();
                oResult = oCompanyBranchBO.Delete(oCompanyBranch);
                if (oResult.IsSuccess)
                {
                    if (oResult.Data.ToString() == "0")
                    {
                        MessageBox.Show("Deletion Not Possible", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        ClearFormData();
                    }
                    else
                    {
                        MessageBox.Show("Deleted successfully");
                        ClearFormData();
                    }
                }



                else
                {
                    MessageBox.Show(oResult.ErrMsg);
                }
                LoadAllCompanyBranch();
            }
        }
Ejemplo n.º 2
0
        private CCompanyBranch GetFormData()
        {
            CCompanyBranch oCompanyBranch = new CCompanyBranch();

            oCompanyBranch.CompBrn_OId          = this.txtOId.Text;
            oCompanyBranch.CompBrn_Branch       = currentBranch.CompBrn_Code;
            oCompanyBranch.CompBrn_Code         = this.txtCode.Text;
            oCompanyBranch.CompBrn_Name         = this.txtName.Text;
            oCompanyBranch.CompBrn_TIN          = this.txtTIN.Text;
            oCompanyBranch.CompBrn_FullName     = this.txtFullName.Text;
            oCompanyBranch.CompBrn_Street       = this.txtStreet.Text;
            oCompanyBranch.CompBrn_Road         = this.txtRoad.Text;
            oCompanyBranch.CompBrn_City         = this.txtCity.Text;
            oCompanyBranch.CompBrn_Country      = this.txtCountry.Text;
            oCompanyBranch.CompBrn_Phone        = this.txtPhone.Text;
            oCompanyBranch.CompBrn_Mobile       = this.txtMobile.Text;
            oCompanyBranch.CompBrn_Email        = this.txtEmail.Text;
            oCompanyBranch.CompBrn_Web          = this.txtWeb.Text;
            oCompanyBranch.CompBrn_PostalCode   = this.txtPostalCode.Text;
            oCompanyBranch.Creator              = currentUser.User_OID;
            oCompanyBranch.CreationDate         = DateTime.Now;
            oCompanyBranch.UpdateBy             = currentUser.User_OID;
            oCompanyBranch.UpdateDate           = DateTime.Now;
            oCompanyBranch.IsActive             = this.chkIsActive.Checked ? "Y" : "N";
            oCompanyBranch.CompBrn_IsHeadoffice = this.chkIsHeadOffice.Checked ? "Y" : "N";
            return(oCompanyBranch);
        }
Ejemplo n.º 3
0
            private CCompanyBranch GetResultSetToCompanyBranch(DataRow dr)
            {
                CCompanyBranch oCompanyBranch = new CCompanyBranch();
                int            iIndex         = 0;

                oCompanyBranch.CompBrn_OId        = dr[iIndex++].ToString();
                oCompanyBranch.CompBrn_Branch     = dr[iIndex++].ToString();
                oCompanyBranch.CompBrn_Code       = dr[iIndex++].ToString();
                oCompanyBranch.CompBrn_Name       = dr[iIndex++].ToString();
                oCompanyBranch.CompBrn_FullName   = dr[iIndex++].ToString();
                oCompanyBranch.CompBrn_Street     = dr[iIndex++].ToString();
                oCompanyBranch.CompBrn_Road       = dr[iIndex++].ToString();
                oCompanyBranch.CompBrn_City       = dr[iIndex++].ToString();
                oCompanyBranch.CompBrn_Country    = dr[iIndex++].ToString();
                oCompanyBranch.CompBrn_Phone      = dr[iIndex++].ToString();
                oCompanyBranch.CompBrn_Mobile     = dr[iIndex++].ToString();
                oCompanyBranch.CompBrn_Email      = dr[iIndex++].ToString();
                oCompanyBranch.CompBrn_Web        = dr[iIndex++].ToString();
                oCompanyBranch.CompBrn_PostalCode = dr[iIndex++].ToString();
                oCompanyBranch.Creator            = dr[iIndex++].ToString();
                oCompanyBranch.CreationDate       = DateTime.Parse(dr[iIndex++].ToString());
                oCompanyBranch.UpdateBy           = dr[iIndex++].ToString();
                oCompanyBranch.UpdateDate         = DateTime.Parse(dr[iIndex++].ToString());
                oCompanyBranch.IsActive           = dr[iIndex++].ToString();

                oCompanyBranch.CompBrn_TIN          = dr[iIndex++].ToString();
                oCompanyBranch.CompBrn_IsHeadoffice = dr[iIndex++].ToString();
                return(oCompanyBranch);
            }
Ejemplo n.º 4
0
        private void SetDefaultValue()
        {
            for (int i = 0; i < dgItemList.Rows.Count; i++)
            {
                DataGridViewComboBoxCell cmbSrcBrn = ((DataGridViewComboBoxCell)dgItemList.Rows[i].Cells["colSrcBranch"]);

                foreach (object obj in cmbSrcBrn.Items)
                {
                    CCompanyBranch oCompanyBranch = (CCompanyBranch)obj;
                    if (oCompanyBranch.CompBrn_OId.Trim() == currentBranch.CompBrn_OId.Trim())
                    {
                        cmbSrcBrn.Value = oCompanyBranch.CompBrn_OId.Trim();
                        break;
                    }
                }

                DataGridViewComboBoxCell cmbSrcInvTyp = ((DataGridViewComboBoxCell)dgItemList.Rows[i].Cells["colSrcInvType"]);
                foreach (object obj in cmbSrcInvTyp.Items)
                {
                    cmbSrcInvTyp.Value = obj;
                    break;
                }

                DataGridViewComboBoxCell cmbDesInvTyp = ((DataGridViewComboBoxCell)dgItemList.Rows[i].Cells["colDesInvType"]);
                foreach (object obj in cmbDesInvTyp.Items)
                {
                    cmbDesInvTyp.Value = obj;
                    break;
                }
            }
        }
Ejemplo n.º 5
0
            public CResult Delete(CCompanyBranch oCompanyBranch)
            {
                oResult = new CResult();
                conn    = oConnManager.GetConnection(out s_DBError);
                if (conn != null)
                {
                    SqlCommand cmd = new SqlCommand();
                    cmd.Connection = conn;
                    cmd.Parameters.Clear();

                    cmd.Transaction = oConnManager.BeginTransaction();
                    try
                    {
                        cmd.CommandText = "sp_CompanyBranch_Delete";
                        cmd.CommandType = CommandType.StoredProcedure;

                        cmd.Parameters.AddWithValue("@CompBrn_OId", oCompanyBranch.CompBrn_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);
            }
Ejemplo n.º 6
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            CCompanyBranch   oCompanyBranch   = GetFormData();
            CCompanyBranchBO oCompanyBranchBO = new CCompanyBranchBO();
            CResult          oResult          = new CResult();

            oResult = oCompanyBranchBO.Create(oCompanyBranch);

            if (oResult.IsSuccess)
            {
                MessageBox.Show("Saved successfully");
            }
            else
            {
                MessageBox.Show(oResult.ErrMsg);
            }
            LoadAllCompanyBranch();
        }
Ejemplo n.º 7
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            CCompanyBranch   oCompanyBranch   = GetFormData();
            CCompanyBranchBO oCompanyBranchBO = new CCompanyBranchBO();
            CResult          oResult          = new CResult();

            if (DialogResult.OK == MessageBox.Show("Are you want to delete " + txtCode.Text + " ?", "Confirmation!", MessageBoxButtons.OKCancel))
            {
                oResult = oCompanyBranchBO.Update(oCompanyBranch);
            }
            if (oResult.IsSuccess)
            {
                MessageBox.Show("Updated successfully");
            }
            else
            {
                MessageBox.Show(oResult.ErrMsg);
            }
            LoadAllCompanyBranch();
        }
Ejemplo n.º 8
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            CCompanyBranch   oCompanyBranch   = GetFormData();
            CCompanyBranchBO oCompanyBranchBO = new CCompanyBranchBO();
            CResult          oResult          = new CResult();

            if (validatedata())
            {
                if (txtOId.Text.Trim() != string.Empty)
                {
                    if (DialogResult.OK == MessageBox.Show("Are you want to Update " + txtCode.Text + " ?", "Confirmation!", MessageBoxButtons.OKCancel))
                    {
                        oResult = oCompanyBranchBO.Update(oCompanyBranch);
                    }
                }

                else
                {
                    if (!IsUpdateMode)
                    {
                        oResult = oCompanyBranchBO.Create(oCompanyBranch);
                    }
                }
                if (oResult.IsSuccess)
                {
                    MessageBox.Show("Saved successfully");
                }
                else
                {
                    //MessageBox.Show(oResult.ErrMsg);
                    MessageBox.Show("Not Saved" + oResult.ErrMsg + "");
                }
                ClearFormData();
                LoadAllCompanyBranch();
            }
        }
Ejemplo n.º 9
0
        private CGRMaster GetToBSavedDataExportBranch()
        {
            oGRFinalQtyDic.Clear();

            CGRMaster oGRMaster = new CGRMaster();

            oGRMaster.GRMstr_OID    = txtSelectedGROID.Text.Trim();
            oGRMaster.GRMstr_Branch = currentBranch.CompBrn_Code;//cmbBranch.SelectedItem.ToString();
            oGRMaster.GRMstr_Code   = txtGRNo.Text.Trim();
            oGRMaster.GRMstr_Type   = Convert.ToInt32(Enum.Parse(typeof(EGRType), ddlType.SelectedItem.ToString()));
            oGRMaster.GRMstr_Date   = dtpGRDate.Value.Date;
            oGRMaster.GRMstr_By     = txtRecievedBy.Text.Trim();
            oGRMaster.Remarks       = txtRemarks.Text.Trim();

            if (currentBranch.CompBrn_OId == "CompBrnXBRN01 0000000001")
            {
                oGRMaster.GRMstr_IsImported = 0;
            }
            else if (currentBranch.CompBrn_OId != "CompBrnXBRN01 0000000001")
            {
                oGRMaster.GRMstr_IsImported = 1;
            }
            // oGRMaster.GRMstr_VendorID = ddlSupplier.SelectedValue.ToString();
            oGRMaster.GRMstr_RefBy = txtRefNo.Text.Trim();


            oGRMaster.Creator      = currentUser.User_OID;
            oGRMaster.CreationDate = DateTime.Now.Date;
            oGRMaster.UpdateBy     = currentUser.User_OID;
            oGRMaster.UpdateDate   = DateTime.Now.Date;
            oGRMaster.IsActive     = "Y";
            oGRMaster.Remarks      = "";


            for (int i = 0; i < dgItemList.Rows.Count - 1; i++)
            {
                if (ValidateListItem(dgItemList.Rows[i]))
                {
                    CGRDetails     oGRDetails     = new CGRDetails();
                    CCompanyBranch oCompanyBranch = (CCompanyBranch)cmbBranch.SelectedItem;
                    oGRDetails.GR_Date      = DateTime.Now.Date;
                    oGRDetails.GRDet_Branch = oCompanyBranch.CompBrn_Code;

                    oGRDetails.GRDet_ItemOID = ((DataGridViewComboBoxCell)dgItemList.Rows[i].Cells["colItemName"]).Value.ToString();
                    if (dgItemList.Rows[i].Cells["colIssueqty"].Value != null)
                    {
                        oGRDetails.GRDet_QTY = float.Parse(((DataGridViewTextBoxCell)dgItemList.Rows[i].Cells["colIssueqty"]).Value.ToString());
                    }

                    if (dgItemList.Rows[i].Cells["colIssueUOM"].Value != null)
                    {
                        oGRDetails.GRDet_UOM = ((DataGridViewComboBoxCell)dgItemList.Rows[i].Cells["colIssueUOM"]).Value.ToString();
                    }

                    oGRDetails.GRDet_BranchOID = currentBranch.CompBrn_OId;

                    if (dgItemList.Rows[i].Cells["colSourceLoc"].Value != null)
                    {
                        oGRDetails.GRDet_LocOID = ((DataGridViewComboBoxCell)dgItemList.Rows[i].Cells["colSourceLoc"]).Value.ToString();
                    }

                    if (dgItemList.Rows[i].Cells["colSrcInvType"].Value != null)
                    {
                        oGRDetails.GRDet_InvType = Convert.ToInt32(Enum.Parse(typeof(EInvType), ((DataGridViewComboBoxCell)dgItemList.Rows[i].Cells["colSrcInvType"]).Value.ToString()));
                    }

                    if (dgItemList.Rows[i].Cells["colPrice"].Value != null)
                    {
                        oGRDetails.GRDet_Price = float.Parse(((DataGridViewTextBoxCell)dgItemList.Rows[i].Cells["colPrice"]).Value.ToString());
                    }
                    if (dgItemList.Rows[i].Cells["colCurrency"].Value != null)
                    {
                        oGRDetails.GRDet_Currency = ((DataGridViewComboBoxCell)dgItemList.Rows[i].Cells["colCurrency"]).Value.ToString();
                    }
                    if (dgItemList.Rows[i].Cells["colAmount"].Value != null)
                    {
                        oGRDetails.GRDet_Amount = float.Parse(((DataGridViewTextBoxCell)dgItemList.Rows[i].Cells["colAmount"]).Value.ToString());
                    }

                    oGRMaster.GRMstr_DetailsList.Add(oGRDetails);


                    CGRDetails oInvGRDetails = new CGRDetails();

                    oInvGRDetails.GRDet_Branch    = oGRDetails.GRDet_Branch;
                    oInvGRDetails.GRDet_BranchOID = oGRDetails.GRDet_BranchOID;
                    oInvGRDetails.GRDet_ItemOID   = oGRDetails.GRDet_ItemOID;
                    oInvGRDetails.GRDet_LocOID    = oGRDetails.GRDet_LocOID;
                    oInvGRDetails.GRDet_InvType   = oGRDetails.GRDet_InvType;
                    if (dgItemList.Rows[i].Cells["colInvtQty"].Value != null)
                    {
                        oInvGRDetails.GRDet_QTY = float.Parse(((DataGridViewTextBoxCell)dgItemList.Rows[i].Cells["colInvtQty"]).Value.ToString());
                    }
                    else
                    {
                        oInvGRDetails.GRDet_QTY = 0.00f;
                    }
                    oGRFinalQtyDic.Add(oInvGRDetails.GRDet_ItemOID, oInvGRDetails);
                }
                else
                {
                    return(null);
                }
            }

            foreach (string obj in oGRExistingQtyDic.Keys)
            {
                if (!oGRFinalQtyDic.ContainsKey(obj))
                {
                    CGRDetails objDetls = new CGRDetails();
                    objDetls.GRDet_Branch    = oGRExistingQtyDic[obj].GRDet_Branch;
                    objDetls.GRDet_BranchOID = oGRExistingQtyDic[obj].GRDet_BranchOID;
                    objDetls.GRDet_InvType   = oGRExistingQtyDic[obj].GRDet_InvType;
                    objDetls.GRDet_ItemOID   = oGRExistingQtyDic[obj].GRDet_ItemOID;
                    objDetls.GRDet_LocOID    = oGRExistingQtyDic[obj].GRDet_LocOID;
                    objDetls.GRDet_QTY       = oGRExistingQtyDic[obj].GRDet_QTY * -1;

                    oGRFinalQtyDic.Add(obj, objDetls);
                }
            }

            return(oGRMaster);
        }
Ejemplo n.º 10
0
            public CResult Import(CCompanyBranch oCompanyBranch)
            {
                oResult = new CResult();
                conn    = oConnManager.GetConnection(out s_DBError);
                if (conn != null)
                {
                    SqlCommand cmd = new SqlCommand();
                    cmd.Connection = conn;
                    cmd.Parameters.Clear();

                    cmd.Transaction = oConnManager.BeginTransaction();
                    try
                    {
                        cmd.CommandText = "sp_CompanyBranch_Import";
                        cmd.CommandType = CommandType.StoredProcedure;

                        cmd.Parameters.AddWithValue("@CompBrn_OId", oCompanyBranch.CompBrn_OId);
                        cmd.Parameters.AddWithValue("@CompBrn_Branch", oCompanyBranch.CompBrn_Branch);
                        cmd.Parameters.AddWithValue("@CompBrn_Code", oCompanyBranch.CompBrn_Code);
                        cmd.Parameters.AddWithValue("@CompBrn_Name", oCompanyBranch.CompBrn_Name);
                        cmd.Parameters.AddWithValue("@CompBrn_FullName", oCompanyBranch.CompBrn_FullName);
                        cmd.Parameters.AddWithValue("@CompBrn_Street", oCompanyBranch.CompBrn_Street);
                        cmd.Parameters.AddWithValue("@CompBrn_Road", oCompanyBranch.CompBrn_Road);
                        cmd.Parameters.AddWithValue("@CompBrn_City", oCompanyBranch.CompBrn_City);
                        cmd.Parameters.AddWithValue("@CompBrn_Country", oCompanyBranch.CompBrn_Country);
                        cmd.Parameters.AddWithValue("@CompBrn_Phone", oCompanyBranch.CompBrn_Phone);
                        cmd.Parameters.AddWithValue("@CompBrn_Mobile", oCompanyBranch.CompBrn_Mobile);
                        cmd.Parameters.AddWithValue("@CompBrn_Email", oCompanyBranch.CompBrn_Email);
                        cmd.Parameters.AddWithValue("@CompBrn_Web", oCompanyBranch.CompBrn_Web);
                        cmd.Parameters.AddWithValue("@CompBrn_PostalCode", oCompanyBranch.CompBrn_PostalCode);
                        cmd.Parameters.AddWithValue("@CompBrn_Creator", oCompanyBranch.Creator);
                        cmd.Parameters.AddWithValue("@CompBrn_CreationDate", oCompanyBranch.CreationDate);
                        cmd.Parameters.AddWithValue("@CompBrn_UpdateBy", oCompanyBranch.UpdateBy);
                        cmd.Parameters.AddWithValue("@CompBrn_UpdateDate", oCompanyBranch.UpdateDate);
                        cmd.Parameters.AddWithValue("@CompBrn_IsActive", oCompanyBranch.IsActive);
                        cmd.Parameters.AddWithValue("@CompBrn_TIN", oCompanyBranch.CompBrn_TIN);
                        cmd.Parameters.AddWithValue("@CompBrn_IsHeadoffice", oCompanyBranch.CompBrn_IsHeadoffice);
                        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);
            }