Esempio n. 1
0
 /// <summary>
 /// Function to Update values in Godown Table
 /// </summary>
 /// <param name="godowninfo"></param>
 public void GodownEdit(GodownInfo godowninfo)
 {
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("GodownEdit", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam       = sccmd.Parameters.Add("@godownId", SqlDbType.Decimal);
         sprmparam.Value = godowninfo.GodownId;
         sprmparam       = sccmd.Parameters.Add("@godownName", SqlDbType.VarChar);
         sprmparam.Value = godowninfo.GodownName;
         sprmparam       = sccmd.Parameters.Add("@narration", SqlDbType.VarChar);
         sprmparam.Value = godowninfo.Narration;
         sprmparam       = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar);
         sprmparam.Value = godowninfo.Extra1;
         sprmparam       = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar);
         sprmparam.Value = godowninfo.Extra2;
         sccmd.ExecuteNonQuery();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         sqlcon.Close();
     }
 }
Esempio n. 2
0
 /// <summary>
 /// Function to save
 /// </summary>
 public void SaveFunction()
 {
     try
     {
         GodownInfo infoGodown = new GodownInfo();
         GodownSP   spGodown   = new GodownSP();
         infoGodown.GodownName = txtGodownName.Text.Trim();
         infoGodown.Narration  = txtNarration.Text.Trim();
         infoGodown.Extra1     = string.Empty;
         infoGodown.Extra2     = string.Empty;
         if (spGodown.GodownCheckIfExist(txtGodownName.Text.Trim(), 0) == false)
         {
             decIdForOtherForms = spGodown.GodownAddWithoutSameName(infoGodown);
             RackAddCurrespondingtoGodown();
             if (decIdForOtherForms > 0)
             {
                 Messages.SavedMessage();
                 Clear();
             }
         }
         else
         {
             Messages.InformationMessage("Godown name already exist");
             txtGodownName.Focus();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("G4:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Esempio n. 3
0
        /// <summary>
        /// Function to get the godownId by godownname
        /// </summary>
        /// <param name="strGodown"></param>
        /// <returns></returns>
        public GodownInfo GodownIdByGodownName(string strGodown)
        {
            GodownInfo    godowninfo = new GodownInfo();
            SqlDataReader sdrreader  = null;

            try
            {
                if (sqlcon.State == ConnectionState.Closed)
                {
                    sqlcon.Open();
                }
                SqlCommand sccmd = new SqlCommand("GodownView", sqlcon);
                sccmd.CommandType = CommandType.StoredProcedure;
                SqlParameter sprmparam = new SqlParameter();
                sprmparam       = sccmd.Parameters.Add("@godownName", SqlDbType.VarChar);
                sprmparam.Value = strGodown;
                sdrreader       = sccmd.ExecuteReader();
                while (sdrreader.Read())
                {
                    godowninfo.GodownId = Convert.ToDecimal(sdrreader[0].ToString());
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                sdrreader.Close();
                sqlcon.Close();
            }
            return(godowninfo);
        }
Esempio n. 4
0
 /// <summary>
 /// Function to fill controls for update
 /// </summary>
 public void FillControls()
 {
     try
     {
         GodownInfo infoGodown = new GodownInfo();
         GodownSP   spGodown   = new GodownSP();
         infoGodown         = spGodown.GodownWithNarrationView(Convert.ToDecimal(dgvGodown.CurrentRow.Cells[1].Value.ToString()));
         txtGodownName.Text = infoGodown.GodownName;
         txtNarration.Text  = infoGodown.Narration;
         btnSave.Text       = "Update";
         btnDelete.Enabled  = true;
         decGodownId        = infoGodown.GodownId;
         strGodownName      = infoGodown.GodownName;
     }
     catch (Exception ex)
     {
         MessageBox.Show("G11:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Esempio n. 5
0
 /// <summary>
 /// Function to insert values to Godown Table with same name
 /// </summary>
 /// <param name="godowninfo"></param>
 /// <returns></returns>
 public decimal GodownAddWithoutSameName(GodownInfo godowninfo)
 {
     // bool isSave = false;
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("GodownAddWithoutSameName", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam       = sccmd.Parameters.Add("@godownName", SqlDbType.VarChar);
         sprmparam.Value = godowninfo.GodownName;
         sprmparam       = sccmd.Parameters.Add("@narration", SqlDbType.VarChar);
         sprmparam.Value = godowninfo.Narration;
         sprmparam       = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar);
         sprmparam.Value = godowninfo.Extra1;
         sprmparam       = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar);
         sprmparam.Value = godowninfo.Extra2;
         decimal decWork = Convert.ToDecimal(sccmd.ExecuteScalar());
         if (decWork > 0)
         {
             return(decWork);
         }
         else
         {
             return(0);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
         return(0);
     }
     finally
     {
         sqlcon.Close();
     }
 }
Esempio n. 6
0
        /// <summary>
        /// Function to Update values in Godown Table
        /// </summary>
        /// <param name="godowninfo"></param>
        /// <returns></returns>
        public bool GodownEditParticularField(GodownInfo godowninfo)
        {
            bool isEdit = false;

            try
            {
                if (sqlcon.State == ConnectionState.Closed)
                {
                    sqlcon.Open();
                }
                SqlCommand sccmd = new SqlCommand("godownEditParticularField", sqlcon);
                sccmd.CommandType = CommandType.StoredProcedure;
                SqlParameter sprmparam = new SqlParameter();
                sprmparam       = sccmd.Parameters.Add("@godownId", SqlDbType.Decimal);
                sprmparam.Value = godowninfo.GodownId;
                sprmparam       = sccmd.Parameters.Add("@godownName", SqlDbType.VarChar);
                sprmparam.Value = godowninfo.GodownName;
                sprmparam       = sccmd.Parameters.Add("@narration", SqlDbType.VarChar);
                sprmparam.Value = godowninfo.Narration;
                int inAffectedRows = sccmd.ExecuteNonQuery();
                if (inAffectedRows > 0)
                {
                    isEdit = true;
                }
                else
                {
                    isEdit = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                sqlcon.Close();
            }
            return(isEdit);
        }
Esempio n. 7
0
 /// <summary>
 /// Function to Edit
 /// </summary>
 public void EditFunction()
 {
     try
     {
         GodownInfo infoGodown = new GodownInfo();
         GodownSP   spGodown   = new GodownSP();
         infoGodown.GodownName = txtGodownName.Text.Trim();
         infoGodown.Narration  = txtNarration.Text.Trim();
         infoGodown.Extra1     = string.Empty;
         infoGodown.Extra2     = string.Empty;
         infoGodown.GodownId   = Convert.ToDecimal(dgvGodown.CurrentRow.Cells["dgvtxtGodownId"].Value.ToString());
         if (txtGodownName.Text != strGodownName)
         {
             if (spGodown.GodownCheckIfExist(txtGodownName.Text.Trim(), decGodownId) == false)
             {
                 if (spGodown.GodownEditParticularField(infoGodown))
                 {
                     Messages.UpdatedMessage();
                     Clear();
                 }
             }
             else
             {
                 Messages.InformationMessage("Godown name already exist");
                 txtGodownName.Focus();
             }
         }
         else
         {
             spGodown.GodownEditParticularField(infoGodown);
             Messages.UpdatedMessage();
             Clear();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("G5:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Esempio n. 8
0
        /// <summary>
        /// Function to get particular values from Godown table based on the parameter
        /// </summary>
        /// <param name="godownId"></param>
        /// <returns></returns>

        public GodownInfo GodownView(decimal godownId)
        {
            GodownInfo    godowninfo = new GodownInfo();
            SqlDataReader sdrreader  = null;

            try
            {
                if (sqlcon.State == ConnectionState.Closed)
                {
                    sqlcon.Open();
                }
                SqlCommand sccmd = new SqlCommand("GodownView", sqlcon);
                sccmd.CommandType = CommandType.StoredProcedure;
                SqlParameter sprmparam = new SqlParameter();
                sprmparam       = sccmd.Parameters.Add("@godownId", SqlDbType.Decimal);
                sprmparam.Value = godownId;
                sdrreader       = sccmd.ExecuteReader();
                while (sdrreader.Read())
                {
                    godowninfo.GodownId   = Convert.ToDecimal(sdrreader[0].ToString());
                    godowninfo.GodownName = sdrreader[1].ToString();
                    godowninfo.Narration  = sdrreader[2].ToString();
                    godowninfo.ExtraDate  = Convert.ToDateTime(sdrreader[3].ToString());
                    godowninfo.Extra1     = sdrreader[4].ToString();
                    godowninfo.Extra2     = sdrreader[5].ToString();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            { sdrreader.Close();
              sqlcon.Close(); }
            return(godowninfo);
        }