Exemple #1
0
        private CSupplier Getformdata()
        {
            CSupplier occs = new CSupplier();

            //
            occs.Cust_OId      = txtOId.Text;
            occs.Cust_Branch   = currentBranch.CompBrn_Code;
            occs.Cust_Id       = txtId.Text;
            occs.Cust_Name     = txtName.Text;
            occs.Cust_CSType   = ECSType.SUPPLIER;
            occs.Cust_ContactP = txtcontactper.Text;
            occs.Cust_Address  = txtaddress.Text;
            occs.Cust_Cell     = txtcell.Text;
            occs.Cust_Phone    = txtphn.Text;
            occs.Cust_Email    = txtemail.Text;
            occs.Cust_Fax      = txtfax.Text;
            occs.Cust_Web      = txtweb.Text;
            occs.Cust_IsActive = chkIsActive.Checked ? "Y":"N";
            occs.Cust_DiscRate = float.Parse(txtdiscrate.Text);

            occs.Creator      = currentUser.User_OID;
            occs.CreationDate = DateTime.Now;
            occs.UpdateBy     = currentUser.User_OID;
            occs.UpdateDate   = DateTime.Now;

            return(occs);
        }
Exemple #2
0
            public CSupplier GetResultSetToCS(DataRow dr)
            {
                CSupplier oCS = new CSupplier();

                oCS.Cust_OId      = CUtils.GetDBValue(dr, 0, "-1").ToString();
                oCS.Cust_Branch   = CUtils.GetDBValue(dr, 1, string.Empty).ToString();
                oCS.Cust_Id       = CUtils.RestoreAPS(CUtils.GetDBValue(dr, 2, string.Empty).ToString());
                oCS.Cust_Name     = CUtils.RestoreAPS(CUtils.GetDBValue(dr, 3, string.Empty).ToString());
                oCS.Cust_CSType   = (ECSType)Enum.Parse(typeof(ECSType), CUtils.GetDBValue(dr, 4, string.Empty).ToString());
                oCS.Cust_ContactP = CUtils.RestoreAPS(CUtils.GetDBValue(dr, 5, string.Empty).ToString());
                oCS.Cust_Address  = CUtils.RestoreAPS(CUtils.GetDBValue(dr, 6, string.Empty).ToString());
                oCS.Cust_Cell     = CUtils.RestoreAPS(CUtils.GetDBValue(dr, 7, string.Empty).ToString());
                oCS.Cust_Phone    = CUtils.RestoreAPS(CUtils.GetDBValue(dr, 8, string.Empty).ToString());
                oCS.Cust_Email    = CUtils.RestoreAPS(CUtils.GetDBValue(dr, 9, string.Empty).ToString());
                oCS.Cust_Fax      = CUtils.RestoreAPS(CUtils.GetDBValue(dr, 10, string.Empty).ToString());
                oCS.Cust_Web      = CUtils.RestoreAPS(CUtils.GetDBValue(dr, 11, string.Empty).ToString());
                oCS.Cust_IsActive = CUtils.RestoreAPS(CUtils.GetDBValue(dr, 12, "N").ToString());
                oCS.Cust_DiscRate = float.Parse(CUtils.GetDBValue(dr, 13, float.MinValue.ToString()).ToString());

                oCS.Creator      = CUtils.RestoreAPS(CUtils.GetDBValue(dr, 14, string.Empty).ToString());
                oCS.CreationDate = DateTime.Parse(CUtils.GetDBValue(dr, 15, "12/12/2007").ToString());
                oCS.UpdateBy     = CUtils.RestoreAPS(CUtils.GetDBValue(dr, 16, string.Empty).ToString());
                oCS.UpdateDate   = DateTime.Parse(CUtils.GetDBValue(dr, 17, "12/12/2007").ToString());

                return(oCS);
            }
Exemple #3
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (validatedata())
     {
         CSupplierBO occsbo  = new CSupplierBO();
         CSupplier   occs    = new CSupplier();
         CResult     oResult = new CResult();
         occs = Getformdata();
         if (this.txtOId.Text.Trim() == string.Empty)
         {
             oResult = occsbo.Create(occs);
         }
         else
         {
             if (DialogResult.OK == MessageBox.Show("Are you wanted to upadte supplier " + txtName.Text + " ?", "Confirmation!", MessageBoxButtons.OKCancel))
             {
                 oResult = occsbo.Update(occs);
             }
         }
         if (oResult.IsSuccess)
         {
             MessageBox.Show("Message saved succesfully", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
             clearformdata();
         }
         else
         {
             MessageBox.Show("Message can not be saved", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
Exemple #4
0
 private void Displaydata(CSupplier objSupplier)
 {
     txtOId.Text         = objSupplier.Cust_OId;
     txtId.Text          = objSupplier.Cust_Id;
     txtName.Text        = objSupplier.Cust_Name;
     txtdiscrate.Text    = objSupplier.Cust_DiscRate.ToString();
     txtcontactper.Text  = objSupplier.Cust_ContactP;
     txtemail.Text       = objSupplier.Cust_Email;
     txtfax.Text         = objSupplier.Cust_Fax;
     txtweb.Text         = objSupplier.Cust_Web;
     txtcell.Text        = objSupplier.Cust_Cell;
     txtaddress.Text     = objSupplier.Cust_Address;
     txtphn.Text         = objSupplier.Cust_Phone;
     chkIsActive.Checked = (objSupplier.Cust_IsActive.ToUpper().Trim() == "Y") ? true : false;
     FormControlMode(1);
 }
Exemple #5
0
            public CResult ReadAll(CSupplier oCS)
            {
                ArrayList oCSList = new ArrayList();

                oResult = new CResult();
                conn    = oConnManager.GetConnection(out s_DBError);
                if (conn != null)
                {
                    try
                    {
                        DataSet    ds  = new DataSet();
                        SqlCommand cmd = new SqlCommand();

                        cmd.Connection  = conn;
                        cmd.CommandText = "sp_Cust_ReadAll";
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.AddWithValue("@Cust_CSType", oCS.Cust_CSType);
                        SqlDataAdapter da = new SqlDataAdapter(cmd);
                        da.Fill(ds);

                        DataTable dt = ds.Tables[0];
                        foreach (DataRow dr in dt.Rows)
                        {
                            oCSList.Add(GetResultSetToCS(dr));
                        }

                        oResult.IsSuccess = true;
                        oResult.Data      = oCSList;
                    }
                    catch (SqlException e)
                    {
                        oResult.IsSuccess = false;
                        oResult.ErrMsg    = e.Message;
                    }
                    finally
                    {
                        oConnManager.Close();
                    }
                }
                else
                {
                    oResult.IsSuccess = false;
                    oResult.ErrMsg    = s_DBError;
                }

                return(oResult);
            }
Exemple #6
0
        private void LoadSupplierData()
        {
            CResult     oResult     = new CResult();
            CSupplierBO oSupplierBO = new CSupplierBO();
            CSupplier   oSupplier   = new CSupplier();

            oSupplier.Cust_CSType = ECSType.SUPPLIER;
            oResult = oSupplierBO.ReadAll(oSupplier);

            if (oResult.IsSuccess)
            {
                arrSupplierList           = oResult.Data as ArrayList;
                ddlSupplier.DataSource    = arrSupplierList;
                ddlSupplier.DisplayMember = "Cust_Name";
                ddlSupplier.ValueMember   = "Cust_OId";
            }
            else
            {
                MessageBox.Show("Loading error...", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #7
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            CSupplierBO occsbo  = new CSupplierBO();
            CSupplier   occs    = new CSupplier();
            CResult     oResult = new CResult();

            //occs = Getformdata();
            if ((MessageBox.Show("Do u really want to delete. ", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning)) == DialogResult.Yes)
            {
                oResult = occsbo.Delete(this.txtOId.Text);
            }

            if (oResult.IsSuccess)
            {
                MessageBox.Show("Deleted Successfully", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                clearformdata();
            }
            else
            {
                MessageBox.Show("Message can not be deleted", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #8
0
        private void LoadSupplierData()
        {
            lvSupplierList.Items.Clear();
            CSupplierBO oSupplierBO = new CSupplierBO();
            CResult     oResult     = new CResult();
            CSupplier   oSupplier   = new CSupplier();

            oResult = oSupplierBO.ReadAll(oSupplier);
            if (oResult.IsSuccess)
            {
                foreach (CSupplier obj in oResult.Data as ArrayList)
                {
                    ListViewItem oItem = new ListViewItem();
                    oItem.Text = obj.Cust_OId.ToString();
                    oItem.SubItems.Add(obj.Cust_Branch).ToString();
                    oItem.SubItems.Add(obj.Cust_Id).ToString();
                    oItem.SubItems.Add(obj.Cust_Name).ToString();
                    oItem.SubItems.Add(obj.Cust_Address).ToString();
                    //  oItem.SubItems.Add(obj.Cust_DiscRate).ToString();
                    oItem.SubItems.Add(obj.Cust_Phone).ToString();
                    oItem.SubItems.Add(obj.Cust_Cell).ToString();
                    oItem.SubItems.Add(obj.Cust_ContactP).ToString();
                    oItem.SubItems.Add(obj.Cust_Fax).ToString();
                    oItem.SubItems.Add(obj.Cust_Web).ToString();
                    oItem.SubItems.Add(obj.Cust_Email).ToString();



                    lvSupplierList.Items.Add(oItem);
                    arrList.Add(obj);
                }
            }
            else
            {
                MessageBox.Show(oResult.ErrMsg.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #9
0
 public EEventArg2(CSupplier objE)
 {
     this.m_Supplier = objE;
 }
Exemple #10
0
            public CResult Update(CSupplier oCS)
            {
                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_Cust_Update";
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.Clear();
                        //
                        cmd.Parameters.AddWithValue("@Cust_OId", oCS.Cust_OId);
                        cmd.Parameters.AddWithValue("@Cust_Branch", oCS.Cust_Branch);
                        cmd.Parameters.AddWithValue("@Cust_Id", oCS.Cust_Id);
                        cmd.Parameters.AddWithValue("@Cust_Name", oCS.Cust_Name);
                        cmd.Parameters.AddWithValue("@Cust_CSType", oCS.Cust_CSType);
                        cmd.Parameters.AddWithValue("@Cust_ContactP", oCS.Cust_ContactP);
                        cmd.Parameters.AddWithValue("@Cust_Address", oCS.Cust_Address);
                        cmd.Parameters.AddWithValue("@Cust_Cell", oCS.Cust_Cell);
                        cmd.Parameters.AddWithValue("@Cust_Phone", oCS.Cust_Phone);
                        cmd.Parameters.AddWithValue("@Cust_Email", oCS.Cust_Email);
                        cmd.Parameters.AddWithValue("@Cust_Fax", oCS.Cust_Fax);
                        cmd.Parameters.AddWithValue("@Cust_Web", oCS.Cust_Web);
                        cmd.Parameters.AddWithValue("@Cust_IsActive", oCS.Cust_IsActive);
                        cmd.Parameters.AddWithValue("@Cust_DiscRate", oCS.Cust_DiscRate);

                        cmd.Parameters.AddWithValue("@Cust_Creator", oCS.Creator);
                        cmd.Parameters.AddWithValue("@Cust_CreationDate", oCS.CreationDate);
                        cmd.Parameters.AddWithValue("@Cust_UpdateBy", oCS.UpdateBy);
                        cmd.Parameters.AddWithValue("@Cust_UpdateDate", oCS.UpdateDate);

                        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);
            }
Exemple #11
0
        //private void btnSupplier_Click(object sender, EventArgs e)
        //{
        //    frmSupplierList ofrmSupplierList = new frmSupplierList();
        //    ofrmSupplierList.EEvent += new frmSupplierList.EEventhandler(ofrmSupplierList_EEvent);
        //    ofrmSupplierList.ShowDialog();
        //}
        void ofrmSupplierList_EEvent(object Sender, EEventArg2 e)
        {
            CSupplier obj = (CSupplier)e.Supplier;

            Displaydata(obj);
        }