コード例 #1
0
ファイル: CompanyInfo.cs プロジェクト: saqibsoft/SoftGrow
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                string vMessage = string.Empty;
                if (txtName.Text.Trim() == string.Empty)
                {
                    vMessage = "Please Insert Company Name!";
                    new Speak().SayIt(vMessage);
                    MessageBox.Show(vMessage, "Information Missing", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    txtName.Focus();
                    return;
                }

                Objects.CompanyInfo obj = new Objects.CompanyInfo();
                obj.CompanyName = txtName.Text.Trim();
                obj.Phone       = txtPhone.Text.Trim();
                obj.Web         = txtWeb.Text.Trim();
                obj.Address     = txtAddress.Text.Trim();



                if (imgLogo.Image != null)
                {
                    MemoryStream ms = new MemoryStream();
                    imgLogo.Image.Save(ms, imgLogo.Image.RawFormat);
                    byte[] arrayImage = ms.GetBuffer();


                    obj.Logo = arrayImage;
                }

                objDAL.DeleteRecord();
                objDAL.InsertRecord(obj);

                //ms.Close(); // Closes the Memory Stream

                vMessage = "Record Saved Successfully.";
                new Speak().SayIt(vMessage);
                MessageBox.Show(vMessage, "Task Completed", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message.ToString(), "Error");
            }
        }
コード例 #2
0
        public void InsertRecord(Objects.CompanyInfo obj)
        {
            try
            {
                SqlCommand cmd = new SqlCommand();
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "SP_InsCompanyInfo";

                cmd.Parameters.AddWithValue("@_CompanyName", obj.CompanyName);
                cmd.Parameters.AddWithValue("@_Address", obj.Address);
                cmd.Parameters.AddWithValue("@_Phone", obj.Phone);
                cmd.Parameters.AddWithValue("@_Web", obj.Web);
                cmd.Parameters.AddWithValue("@_CompanyLogo", obj.Logo);

                new Database(connectionstring).ExecuteNonQueryOnly(cmd);
            }
            catch (Exception exc)
            {
                throw exc;
            }
        }