示例#1
0
        /// <summary>
        /// Function to get particular values from ModelNo table based on the parameter with narration
        /// </summary>
        /// <param name="decModelNoId"></param>
        /// <returns></returns>
        public ModelNoInfo ModelNoWithNarrationView(decimal decModelNoId)
        {
            ModelNoInfo   modelnoinfo = new ModelNoInfo();
            SqlDataReader sdrreader   = null;

            try
            {
                if (sqlcon.State == ConnectionState.Closed)
                {
                    sqlcon.Open();
                }
                SqlCommand sccmd = new SqlCommand("ModelNoWithNarrationView", sqlcon);
                sccmd.CommandType = CommandType.StoredProcedure;
                SqlParameter sprmparam = new SqlParameter();
                sprmparam       = sccmd.Parameters.Add("@modelNoId", SqlDbType.Decimal);
                sprmparam.Value = decModelNoId;
                sdrreader       = sccmd.ExecuteReader();
                while (sdrreader.Read())
                {
                    modelnoinfo.ModelNoId = Convert.ToDecimal(sdrreader[0].ToString());
                    modelnoinfo.ModelNo   = sdrreader[1].ToString();
                    modelnoinfo.Narration = sdrreader[2].ToString();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                sdrreader.Close();
                sqlcon.Close();
            }
            return(modelnoinfo);
        }
示例#2
0
 /// <summary>
 /// Function to Update values in ModelNo Table
 /// </summary>
 /// <param name="modelnoinfo"></param>
 public void ModelNoEdit(ModelNoInfo modelnoinfo)
 {
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("ModelNoEdit", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam       = sccmd.Parameters.Add("@modelNoId", SqlDbType.Decimal);
         sprmparam.Value = modelnoinfo.ModelNoId;
         sprmparam       = sccmd.Parameters.Add("@modelNo", SqlDbType.VarChar);
         sprmparam.Value = modelnoinfo.ModelNo;
         sprmparam       = sccmd.Parameters.Add("@narration", SqlDbType.VarChar);
         sprmparam.Value = modelnoinfo.Narration;
         sprmparam       = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar);
         sprmparam.Value = modelnoinfo.Extra1;
         sprmparam       = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar);
         sprmparam.Value = modelnoinfo.Extra2;
         sccmd.ExecuteNonQuery();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         sqlcon.Close();
     }
 }
示例#3
0
 /// <summary>
 /// Function to save
 /// </summary>
 public void SaveFunction()
 {
     try
     {
         ModelNoSP   spModelNo   = new ModelNoSP();
         ModelNoInfo infoModelNo = new ModelNoInfo();
         infoModelNo.ModelNo   = txtModalNo.Text.Trim();
         infoModelNo.Narration = txtNarration.Text.Trim();
         infoModelNo.Extra1    = string.Empty;
         infoModelNo.Extra2    = string.Empty;
         if (spModelNo.ModelCheckIfExist(txtModalNo.Text.Trim().ToString(), 0) == false)
         {
             decIdForOtherForms = spModelNo.ModelNoAddWithDifferentModelNo(infoModelNo);
             if (decIdForOtherForms > 0)
             {
                 Messages.SavedMessage();
                 Clear();
             }
         }
         else
         {
             Messages.InformationMessage("Model number already exist");
             txtModalNo.Focus();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("MN3" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
示例#4
0
 /// <summary>
 /// Function to edit
 /// </summary>
 public void EditFunction()
 {
     try
     {
         ModelNoSP   spModelNo   = new ModelNoSP();
         ModelNoInfo infoModelNo = new ModelNoInfo();
         infoModelNo.ModelNo   = txtModalNo.Text.Trim();
         infoModelNo.Narration = txtNarration.Text.Trim();
         infoModelNo.Extra1    = string.Empty;
         infoModelNo.Extra2    = string.Empty;
         infoModelNo.ModelNoId = Convert.ToDecimal(dgvModalNo.CurrentRow.Cells[1].Value.ToString());
         if (txtModalNo.Text != strModelNo)
         {
             if (spModelNo.ModelCheckIfExist(txtModalNo.Text.Trim(), decModelNo) == false)
             {
                 if (spModelNo.ModelNoEditParticularFeilds(infoModelNo))
                 {
                     Messages.UpdatedMessage();
                     Clear();
                 }
                 else if (infoModelNo.ModelNoId == 1)
                 {
                     Messages.InformationMessage("Cannot update");
                     Clear();
                     txtModalNo.Focus();
                 }
             }
             else
             {
                 Messages.InformationMessage("Model number already exist");
                 txtModalNo.Focus();
             }
         }
         else
         {
             spModelNo.ModelNoEditParticularFeilds(infoModelNo);
             Messages.UpdatedMessage();
             Clear();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("MN4" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
示例#5
0
 /// <summary>
 /// Function to fill controls for update
 /// </summary>
 public void FillControls()
 {
     try
     {
         ModelNoInfo infoModelNo = new ModelNoInfo();
         ModelNoSP   spModelNo   = new ModelNoSP();
         infoModelNo       = spModelNo.ModelNoWithNarrationView(Convert.ToDecimal(dgvModalNo.CurrentRow.Cells[1].Value.ToString()));
         txtModalNo.Text   = infoModelNo.ModelNo;
         txtNarration.Text = infoModelNo.Narration;
         btnSave.Text      = "Update";
         btnDelete.Enabled = true;
         decModelNo        = infoModelNo.ModelNoId;
         strModelNo        = infoModelNo.ModelNo;
     }
     catch (Exception ex)
     {
         MessageBox.Show("MN8" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
示例#6
0
        /// <summary>
        /// Function to Update values in ModelNo Table
        /// </summary>
        /// <param name="modelnoinfo"></param>
        /// <returns></returns>
        public bool ModelNoEditParticularFeilds(ModelNoInfo modelnoinfo)
        {
            bool isEdit = false;

            try
            {
                if (sqlcon.State == ConnectionState.Closed)
                {
                    sqlcon.Open();
                }
                SqlCommand sccmd = new SqlCommand("ModelNoEditParticularFeild", sqlcon);
                sccmd.CommandType = CommandType.StoredProcedure;
                SqlParameter sprmparam = new SqlParameter();
                sprmparam       = sccmd.Parameters.Add("@modelNoId", SqlDbType.Decimal);
                sprmparam.Value = modelnoinfo.ModelNoId;
                sprmparam       = sccmd.Parameters.Add("@modelNo", SqlDbType.VarChar);
                sprmparam.Value = modelnoinfo.ModelNo;
                sprmparam       = sccmd.Parameters.Add("@narration", SqlDbType.VarChar);
                sprmparam.Value = modelnoinfo.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);
        }
示例#7
0
 /// <summary>
 /// Function to add modelNo to modelNo table with differnt modelNo
 /// </summary>
 /// <param name="modelnoinfo"></param>
 /// <returns></returns>
 public decimal ModelNoAddWithDifferentModelNo(ModelNoInfo modelnoinfo)
 {
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("ModelNoAddWithDifferentModelNo", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam       = sccmd.Parameters.Add("@modelNo", SqlDbType.VarChar);
         sprmparam.Value = modelnoinfo.ModelNo;
         sprmparam       = sccmd.Parameters.Add("@narration", SqlDbType.VarChar);
         sprmparam.Value = modelnoinfo.Narration;
         sprmparam       = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar);
         sprmparam.Value = modelnoinfo.Extra1;
         sprmparam       = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar);
         sprmparam.Value = modelnoinfo.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();
     }
 }