Пример #1
0
        private void LoadALLBVL()
        {
            lvCVBList.Items.Clear();
            CCVBBO  oCVBBO  = new CCVBBO();
            CResult oResult = new CResult();
            CCVB    oCVB    = new CCVB();

            oResult = oCVBBO.ReadAllBVL(oCVB);
            if (oResult.IsSuccess)
            {
                foreach (CCVB obj in oResult.Data as ArrayList)
                {
                    ListViewItem oItem = new ListViewItem();

                    oItem.Text = obj.OID.ToString();
                    oItem.SubItems.Add(obj.Bran_OID).ToString();
                    oItem.SubItems.Add(obj.Loc_OID).ToString();
                    oItem.SubItems.Add(obj.Branch).ToString();
                    oItem.SubItems.Add(obj.Location).ToString();


                    lvCVBList.Items.Add(oItem);
                }
            }
            else
            {
                MessageBox.Show(oResult.ErrMsg.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #2
0
        private CCVB GetToSaveData()
        {
            CCVB oCVB = new CCVB();

            oCVB.OID     = txtHiddenOID.Text;
            oCVB.Company = cmbCompany.SelectedValue.ToString();
            oCVB.Branch  = cmbBranch.SelectedValue.ToString();

            return(oCVB);
        }
Пример #3
0
            public CResult ReadAll(CCVB objCVB)
            {
                List <CCVB> oCVBList = new List <CCVB>();

                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 = "Select * from t_BVL ";
                        cmd.CommandType = CommandType.Text;


                        SqlDataReader oReader = cmd.ExecuteReader();

                        if (oReader.HasRows)
                        {
                            while (oReader.Read())
                            {
                                CCVB oCVB = new CCVB();
                                oCVB.OID      = oReader["BVL_OID"].ToString();
                                oCVB.Branch   = oReader["BVL_Branch"].ToString();
                                oCVB.Location = oReader["BVL_Location"].ToString();

                                oCVBList.Add(oCVB);
                            }
                            oReader.Close();
                        }

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

                return(oResult);
            }
Пример #4
0
            private CCVB GetresultoCVB(DataRow dr)
            {
                CCVB oCVB = new CCVB();

                oCVB.OID      = dr[0].ToString();
                oCVB.Comp_OID = dr[1].ToString();
                oCVB.Bran_OID = dr[2].ToString();
                oCVB.Company  = dr[3].ToString();
                oCVB.Branch   = dr[4].ToString();


                return(oCVB);
            }
Пример #5
0
            public CResult ReadAllBVL(CCVB oCVB)
            {
                ArrayList oCVBList = new ArrayList();

                oResult = new CResult();
                conn    = oConnManager.GetConnection(out s_DBError);
                if (conn != null)
                {
                    try
                    {
                        SqlCommand cmd = new SqlCommand();
                        cmd.Connection  = conn;
                        cmd.CommandText = "sp_ReadAllBVL";
                        cmd.CommandType = CommandType.StoredProcedure;

                        DataSet        ds = new DataSet();
                        SqlDataAdapter da = new SqlDataAdapter(cmd);
                        da.Fill(ds);
                        DataTable dt = ds.Tables[0];

                        foreach (DataRow dr in dt.Rows)
                        {
                            oCVBList.Add(GetresultoBVL(dr));
                        }


                        oResult.Data = oCVBList;

                        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);
            }
Пример #6
0
            public CResult Import(CCVB oCVB)
            {
                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_CVB_Import";
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.AddWithValue("@CVB_OID", oCVB.OID);
                        cmd.Parameters.AddWithValue("@CVB_Company", oCVB.Comp_OID);
                        cmd.Parameters.AddWithValue("@CVB_Branch", oCVB.Bran_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);
            }
Пример #7
0
        private void LoadRelationData()
        {
            CResult             oResult = new CResult();
            CCVB                oCVB    = new CCVB();
            CMaterialTransferBO oMTBO   = new CMaterialTransferBO();

            oResult = oMTBO.ReadAll(oCVB);

            if (oResult.IsSuccess)
            {
                oCVBList = oResult.Data as List <CCVB>;
            }
            else
            {
                MessageBox.Show("Loading error...", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }