Пример #1
0
 /// <summary>
 /// Function to Update values in Size Table
 /// </summary>
 /// <param name="sizeinfo"></param>
 public void SizeEdit(SizeInfo sizeinfo)
 {
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("SizeEdit", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam       = sccmd.Parameters.Add("@sizeId", SqlDbType.Decimal);
         sprmparam.Value = sizeinfo.SizeId;
         sprmparam       = sccmd.Parameters.Add("@size", SqlDbType.VarChar);
         sprmparam.Value = sizeinfo.Size;
         sprmparam       = sccmd.Parameters.Add("@narration", SqlDbType.VarChar);
         sprmparam.Value = sizeinfo.Narration;
         sprmparam       = sccmd.Parameters.Add("@extraDate", SqlDbType.DateTime);
         sprmparam.Value = sizeinfo.ExtraDate;
         sprmparam       = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar);
         sprmparam.Value = sizeinfo.Extra1;
         sprmparam       = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar);
         sprmparam.Value = sizeinfo.Extra2;
         sccmd.ExecuteNonQuery();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         sqlcon.Close();
     }
 }
Пример #2
0
        /// <summary>
        /// Function to Update values in Size Table and return the status
        /// </summary>
        /// <param name="infoSize"></param>
        /// <returns></returns>
        public bool SizeEditing(SizeInfo infoSize)
        {
            bool isEdit = false;

            try
            {
                if (sqlcon.State == ConnectionState.Closed)
                {
                    sqlcon.Open();
                }
                SqlCommand sqlcmd = new SqlCommand("SizeEditing", sqlcon);
                sqlcmd.CommandType = CommandType.StoredProcedure;
                sqlcmd.Parameters.Add("@sizeId", SqlDbType.Decimal).Value    = infoSize.SizeId;
                sqlcmd.Parameters.Add("@size", SqlDbType.VarChar).Value      = infoSize.Size;
                sqlcmd.Parameters.Add("@narration", SqlDbType.VarChar).Value = infoSize.Narration;
                int ineffectedrow = sqlcmd.ExecuteNonQuery();
                if (ineffectedrow > 0)
                {
                    isEdit = true;
                }
                else
                {
                    isEdit = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                sqlcon.Close();
            }
            return(isEdit);
        }
Пример #3
0
        /// <summary>
        /// Function to get  values from Size Table based on the parameter
        /// </summary>
        /// <param name="decSizeId"></param>
        /// <returns></returns>
        public SizeInfo SizeViewing(decimal decSizeId)
        {
            SizeInfo      infoSize = new SizeInfo();
            SqlDataReader sqldr    = null;

            try
            {
                if (sqlcon.State == ConnectionState.Closed)
                {
                    sqlcon.Open();
                }
                SqlCommand sqlcmd = new SqlCommand("SizeViewing", sqlcon);
                sqlcmd.CommandType = CommandType.StoredProcedure;
                sqlcmd.Parameters.Add("@sizeId", SqlDbType.Decimal).Value = decSizeId;
                sqldr = sqlcmd.ExecuteReader();
                while (sqldr.Read())
                {
                    infoSize.SizeId    = decimal.Parse(sqldr["SizeId"].ToString());
                    infoSize.Size      = sqldr["Size"].ToString();
                    infoSize.Narration = sqldr["Narration"].ToString();
                    infoSize.Extra1    = sqldr["Extra1"].ToString();
                    infoSize.Extra2    = sqldr["Extra2"].ToString();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                sqldr.Close();
                sqlcon.Close();
            }
            return(infoSize);
        }
Пример #4
0
 /// <summary>
 /// Function to insert values to Size Table and return the Curresponding row's Id
 /// </summary>
 /// <param name="infoSize"></param>
 /// <returns></returns>
 public decimal SizeAdding(SizeInfo infoSize)
 {
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sqlcmd = new SqlCommand("SizeAdding", sqlcon);
         sqlcmd.CommandType = CommandType.StoredProcedure;
         sqlcmd.Parameters.Add("@size", SqlDbType.VarChar).Value      = infoSize.Size;
         sqlcmd.Parameters.Add("@narration", SqlDbType.VarChar).Value = infoSize.Narration;
         sqlcmd.Parameters.Add("@extra1", SqlDbType.VarChar).Value    = infoSize.Extra1;
         sqlcmd.Parameters.Add("@extra2", SqlDbType.VarChar).Value    = infoSize.Extra2;
         decimal deceffectedrow = Convert.ToDecimal(sqlcmd.ExecuteScalar());
         if (deceffectedrow > 0)
         {
             return(deceffectedrow);
         }
         else
         {
             return(0);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
         return(0);
     }
     finally
     {
         sqlcon.Close();
     }
 }
Пример #5
0
 /// <summary>
 /// Save Function
 /// </summary>
 public void SaveFunction()
 {
     try
     {
         SizeSP   spSize   = new SizeSP();
         SizeInfo infoSize = new SizeInfo();
         infoSize.Size      = txtSize.Text.Trim();
         infoSize.Narration = txtNarration.Text.Trim();
         infoSize.Extra1    = String.Empty;
         infoSize.Extra2    = String.Empty;
         if (spSize.SizeNameCheckExistence(txtSize.Text.Trim().ToString(), 0) == false)
         {
             decIdentity = spSize.SizeAdding(infoSize);
             if (decIdentity > 0)
             {
                 Messages.SavedMessage();
                 GridFill();
                 Clear();
             }
         }
         else
         {
             Messages.InformationMessage(" Size already exist");
             txtSize.Focus();
         }
     }
     catch (Exception ex)
     {
         formMDI.infoError.ErrorString = "SZ2" + ex.Message;
     }
 }
Пример #6
0
 /// <summary>
 /// Grid cell double click for update or delete
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void dgvSize_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
 {
     try
     {
         if (e.RowIndex != -1)
         {
             if (dgvSize.CurrentRow.Cells["dgvtxtsizeId"].Value != null && dgvSize.CurrentRow.Cells["dgvtxtsizeId"].Value.ToString() != string.Empty)
             {
                 decSizeId = Convert.ToDecimal(dgvSize.CurrentRow.Cells["dgvtxtsizeId"].Value.ToString());
                 if (decSizeId != 1)
                 {
                     SizeSP   spSize   = new SizeSP();
                     SizeInfo infoSize = new SizeInfo();
                     infoSize          = spSize.SizeViewing(decSizeId);
                     txtSize.Text      = infoSize.Size;
                     txtNarration.Text = infoSize.Narration;
                     btnSave.Text      = "Update";
                     btnDelete.Enabled = true;
                     txtSize.Focus();
                 }
                 else
                 {
                     Messages.InformationMessage(" NA Size canot update or delete");
                     Clear();
                 }
             }
         }
     }
     catch (Exception ex)
     {
         formMDI.infoError.ErrorString = "SZ12" + ex.Message;
     }
 }
Пример #7
0
 /// <summary>
 /// Edit Function
 /// </summary>
 public void EditFunction()
 {
     try
     {
         SizeSP   spSize   = new SizeSP();
         SizeInfo infoSize = new SizeInfo();
         infoSize.Size      = txtSize.Text.Trim();
         infoSize.Narration = txtNarration.Text.Trim();
         infoSize.Extra1    = String.Empty;
         infoSize.Extra2    = String.Empty;
         infoSize.SizeId    = decSizeId;
         if (spSize.SizeNameCheckExistence(txtSize.Text.Trim().ToString(), decSizeId) == false)
         {
             if (spSize.SizeEditing(infoSize))
             {
                 Messages.UpdatedMessage();
                 GridFill();
                 Clear();
             }
         }
         else
         {
             Messages.InformationMessage("Size already exist");
             txtSize.Focus();
         }
     }
     catch (Exception ex)
     {
         formMDI.infoError.ErrorString = "SZ3" + ex.Message;
     }
 }
Пример #8
0
        /// <summary>
        /// Function to get particular values from Size Table based on the parameter
        /// </summary>
        /// <param name="sizeId"></param>
        /// <returns></returns>
        public SizeInfo SizeView(decimal sizeId)
        {
            SizeInfo      sizeinfo  = new SizeInfo();
            SqlDataReader sdrreader = null;

            try
            {
                if (sqlcon.State == ConnectionState.Closed)
                {
                    sqlcon.Open();
                }
                SqlCommand sccmd = new SqlCommand("SizeView", sqlcon);
                sccmd.CommandType = CommandType.StoredProcedure;
                SqlParameter sprmparam = new SqlParameter();
                sprmparam       = sccmd.Parameters.Add("@sizeId", SqlDbType.Decimal);
                sprmparam.Value = sizeId;
                sdrreader       = sccmd.ExecuteReader();
                while (sdrreader.Read())
                {
                    sizeinfo.SizeId    = decimal.Parse(sdrreader[0].ToString());
                    sizeinfo.Size      = sdrreader[1].ToString();
                    sizeinfo.Narration = sdrreader[2].ToString();
                    sizeinfo.ExtraDate = DateTime.Parse(sdrreader[3].ToString());
                    sizeinfo.Extra1    = sdrreader[4].ToString();
                    sizeinfo.Extra2    = sdrreader[5].ToString();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                sdrreader.Close();
                sqlcon.Close();
            }
            return(sizeinfo);
        }