예제 #1
0
        private void Delete()
        {
            if (BTNSAVE.Enabled || txtID.Text == "")
            {
                return;
            }
            if (luestate.EditValue.ToString() == "1")
            {
                //已批準狀態,不可以刪除!
                MessageBox.Show(clsCommon.GetTitle("t_ check_is_can_delete"), myMsg.msgTitle, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            DialogResult dialogResult = MessageBox.Show(myMsg.msgIsDelete, myMsg.msgTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (dialogResult == DialogResult.Yes)
            {
                int    ls_result;
                string sql_d = string.Format(@"UPDATE dbo.bs_productline Set state = '2' WHERE id = '{0}'", txtID.Text);
                ls_result = clsApp.ExecuteSqlUpdate(sql_d);
                if (ls_result > 0)
                {
                    MessageBox.Show(myMsg.msgSave_ok, myMsg.msgTitle, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show(myMsg.msgSave_error, myMsg.msgTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
예제 #2
0
파일: frmSysPopedom.cs 프로젝트: cfmis/cfvn
 //刪除用戶
 private void contextMenuStrip_user_del_user_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("真的要刪除此条记录?", "提示信息", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
     {
         string sql_del = string.Format(@"DELETE FROM sys_user WHERE user_id='{0}'", cur_node_user_id);
         if (clsApp.ExecuteSqlUpdate(sql_del) > 0)
         {
             cur_node_selected.Remove(); //移除當前用戶節點
             MessageBox.Show("刪除当前记录成功", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         else
         {
             MessageBox.Show("刪除当前记录失败", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Stop);
         }
     }
 }
예제 #3
0
        private void btnCancel_Click(object sender, EventArgs e)
        {
            if (txtpkey.Text == "")
            {
                return;
            }
            if (cur_node_typeid == "G")
            {
                MessageBox.Show("组节点不可注销!", "提示信息");
                return;
            }

            string sql_u = string.Format(@"UPDATE sys_menu_window SET status='2' Where pkey={0}", int.Parse(txtpkey.Text));

            if (MessageBox.Show("注销后菜单将不会出现在系統菜单界面,是否要注销此菜单?", "提示信息", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                int result = clsApp.ExecuteSqlUpdate(sql_u);
                if (result > 0)
                {
                    node_cur_selected.Remove();
                    MessageBox.Show("当前菜单项注销成功!", "提示信息");
                }
                else
                {
                    MessageBox.Show("当前菜单项注销失败!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
예제 #4
0
        private void Delete() //刪除當前行
        {
            if (String.IsNullOrEmpty(txtid.Text))
            {
                return;
            }

            if (clsArtwork.Is_Used_in_mm_master(txtid.Text, "datum"))
            {
                MessageBox.Show("Please note this material type code is used in goods master", "System info");
                return;
            }

            DialogResult dlg_result = MessageBox.Show(myMsg.msgIsDelete, myMsg.msgTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (dlg_result == DialogResult.Yes)
            {
                string sql_u     = string.Format(@"UPDATE dbo.bs_mat_type SET state='2' WHERE id='{0}'", txtid.Text);
                int    li_result = clsApp.ExecuteSqlUpdate(sql_u);
                if (li_result > 0)
                {
                    MessageBox.Show(myMsg.msgSave_ok, myMsg.msgTitle, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show(myMsg.msgSave_error, myMsg.msgTitle, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }
예제 #5
0
        private void Inport_excel(string _filename, string _strsql)
        {
            String connStr = String.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0}; Extended Properties=Excel 8.0;", _filename);

            using (OleDbDataAdapter da = new OleDbDataAdapter(_strsql, connStr))
            {
                DataSet ds = new DataSet();
                da.Fill(ds);
                string        strUser_id = DBUtility._user_id;
                DataTable     dtExcel    = ds.Tables[0];
                SqlConnection sqlconn    = new SqlConnection(DBUtility.ConnectionString);
                sqlconn.Open();

                string strSql_u;
                progressBar1.Enabled = true;
                progressBar1.Visible = true;
                progressBar1.Value   = 0;
                progressBar1.Step    = 1;
                progressBar1.Maximum = dtExcel.Rows.Count;
                int intFlag = 0;
                for (int i = 0; i < dtExcel.Rows.Count; i++)
                {
                    progressBar1.Value += progressBar1.Step;
                    if (progressBar1.Value == progressBar1.Maximum)
                    {
                        progressBar1.Enabled = false;
                        progressBar1.Visible = false;
                    }
                    strSql_u = string.Format(
                        @"EXECUTE usp_update_cust_info '{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}'",
                        dtExcel.Rows[i]["客户名称"].ToString().Trim(),
                        dtExcel.Rows[i]["客户送货地址"].ToString().Trim(),
                        dtExcel.Rows[i]["联系人"].ToString().Trim(),
                        dtExcel.Rows[i]["联系电话"].ToString().Trim(),
                        dtExcel.Rows[i]["传真"].ToString().Trim(),
                        dtExcel.Rows[i]["电邮"].ToString().Trim(),
                        dtExcel.Rows[i]["省份或城市"].ToString().Trim(),
                        strUser_id);
                    intFlag = clsApp.ExecuteSqlUpdate(strSql_u);
                    if (intFlag < 0)
                    {
                        MessageBox.Show(string.Format("更新客户名称:【{0}】出错!", dtExcel.Rows[i]["客户名称"].ToString().Trim()));
                        break;
                    }
                }
                progressBar1.Enabled = false;
                progressBar1.Visible = false;
                sqlconn.Close();
                sqlconn.Dispose();
            }
        }
예제 #6
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            if (txtNewpwd.Text == txtPwdconfirm.Text)
            {
                if (txtNewpwd.Text == "")
                {
                    MessageBox.Show("密码不可以为空!");
                    txtNewpwd.Focus();
                    return;
                }

                string strEncrypt = clsPublic.GeoEncrypt(txtNewpwd.Text);
                string sql_u      = string.Format(@"Update dbo.sys_user SET password='******' WHERE user_id='{1}'", strEncrypt, txtUser_id.Text);
                if (clsApp.ExecuteSqlUpdate(sql_u) > 0)
                {
                    MessageBox.Show("密码修改成功!");
                }
            }
            else
            {
                MessageBox.Show("新密码输入不一致!");
                txtNewpwd.Focus();
            }
        }
예제 #7
0
파일: frmDelivery.cs 프로젝트: cfmis/cfvn
        private void Save()          //保存
        {
            txtremark.Focus();
            if (!Save_Before_Valid())
            {
                return;
            }
            if (dgvDetails.RowCount == 0)
            {
                MessageBox.Show("表格明细资料不可为空 !", "提示信息");
                return;
            }
            if (!Check_Details_Valid())            //检查明细资料的有效性
            {
                return;
            }

            save_flag = false;
            myBDS1.EndEdit();
            myBDS2.EndEdit();
            dgvDetails.CloseEditor();

            #region  保存新增或編輯
            if (mState == "NEW" || mState == "EDIT")
            {
                string strSql;
                if (mState == "NEW")
                {
                    strSql = String.Format("Select '1' FROM dbo.delivery_mostly WHERE id='{0}'", txtID.Text);
                    if (clsApp.ExecuteSqlReturnObject(strSql) != "")
                    {
                        //MessageBox.Show(string.Format("此公司数据[{0}]已存在!", txtID.EditValue));
                        //return;
                        //如已存在編號則重取最大單據編號
                        //GetID_No();
                        txtID.Text = clsApp.ExecuteSqlReturnObject(@"Select dbo.fn_get_max_no('T') AS max_no");
                    }
                    clsApp.ExecuteSqlUpdate(@"EXECUTE usp_set_max_no 'T'"); //更新最大单据号加1
                }

                //if (txtcustomer_address.Text != "")
                //{
                //    strSql = string.Format(@"EXECUTE usp_update_address_history '{0}','{1}','{2}','{3}'", txtcompany_id.EditValue, txtcustomer_address.Text, txtserial_no.Text, txtserial_name.Text);
                //    clsApp.ExecuteSqlUpdate(strSql); //更新客户地址区域对照表
                //}

                const string sql_i =
                    @"INSERT INTO dbo.delivery_mostly(id,delivery_date,customer_name,customer_address,contact,customer_tel,
                 customer_fax,company_id,serial_no,serial_name,amt_sum,remark,province,state,create_by,create_date) VALUES 
                 (@id,@delivery_date,@customer_name,@customer_address,@contact,@customer_tel,@customer_fax,
                  @company_id,@serial_no,@serial_name,@amt_sum,@remark,@province,@state,@user_id,getdate())";
                const string sql_u =
                    @"Update dbo.delivery_mostly SET delivery_date=@delivery_date,customer_name=@customer_name,customer_address=@customer_address,
                  contact=@contact,customer_tel=@customer_tel,customer_fax=@customer_fax,company_id=@company_id,serial_no=@serial_no,
                  serial_name=@serial_name,amt_sum=@amt_sum,remark=@remark,province=@province,state=@state,update_by=@user_id,update_date=getdate() 
                  WHERE id=@id";

                SqlConnection myCon = new SqlConnection(DBUtility.ConnectionString); //改爲CF01
                myCon.Open();
                SqlTransaction myTrans = myCon.BeginTransaction();
                using (SqlCommand myCommand = new SqlCommand()
                {
                    Connection = myCon, Transaction = myTrans
                })
                {
                    try
                    {
                        if (mState == "NEW")
                        {
                            myCommand.CommandText = sql_i;
                        }
                        else
                        {
                            myCommand.CommandText = sql_u;
                        }
                        myCommand.Parameters.Clear();
                        myCommand.Parameters.AddWithValue("@id", txtID.Text);
                        myCommand.Parameters.AddWithValue("@delivery_date", clsPub.Return_String_Date(dtDelivery_date.Text));
                        myCommand.Parameters.AddWithValue("@customer_name", txtcustomer_name.Text);
                        myCommand.Parameters.AddWithValue("@customer_address", txtcustomer_address.Text);
                        myCommand.Parameters.AddWithValue("@contact", txtcontact.Text);
                        myCommand.Parameters.AddWithValue("@customer_tel", txtcustomer_tel.Text);
                        myCommand.Parameters.AddWithValue("@customer_fax", txtcustomer_fax.Text);
                        myCommand.Parameters.AddWithValue("@company_id", txtcompany_id.EditValue.ToString());
                        myCommand.Parameters.AddWithValue("@serial_no", txtserial_no.EditValue.ToString());
                        myCommand.Parameters.AddWithValue("@serial_name", txtserial_name.Text);
                        myCommand.Parameters.AddWithValue("@amt_sum", clsPub.Return_Float_Value(txtamt_sum.Text));
                        myCommand.Parameters.AddWithValue("@remark", txtremark.Text);
                        myCommand.Parameters.AddWithValue("@province", lkeProvince.EditValue);
                        myCommand.Parameters.AddWithValue("@state", "0");
                        myCommand.Parameters.AddWithValue("@user_id", DBUtility._user_id);
                        myCommand.ExecuteNonQuery();

                        //處理【項目刪除】刪除明細資料
                        bool   is_large;
                        string sql_item_d;
                        for (int i = 0; i < dtTempDel.Rows.Count; i++)
                        {
                            //刪除明細
                            sql_item_d            = @"DELETE FROM dbo.delivery_details WHERE id=@id and sequence_id=@sequence_id";
                            myCommand.CommandText = sql_item_d;
                            myCommand.Parameters.Clear();
                            myCommand.Parameters.AddWithValue("@id", txtID.Text);
                            myCommand.Parameters.AddWithValue("@sequence_id", dtTempDel.Rows[i]["sequence_id"].ToString());

                            myCommand.ExecuteNonQuery();
                        }

                        //保存明細
                        int    curRow;
                        string rowStatus;
                        if (dgvDetails.RowCount > 0)
                        {
                            const string sql_item_i =
                                @"INSERT INTO dbo.delivery_details
                                (id,sequence_id,is_large,goods_id,sec_qty,amt_total,amt_other,rmk) values(@id,@sequence_id,@is_large,@goods_id,@sec_qty,@amt_total,@amt_other,@rmk)";
                            const string sql_item_u =
                                @"Update dbo.delivery_details 
                                SET is_large=@is_large,goods_id=@goods_id,sec_qty=@sec_qty,amt_total=@amt_total,amt_other=@amt_other,rmk=@rmk 
                                Where id=@id AND sequence_id=@sequence_id";

                            for (int i = 0; i < dgvDetails.RowCount; i++)
                            {
                                curRow = dgvDetails.GetRowHandle(i);
                                //dgvDetails.AddNewRow();//新增必須初始貨當前單元格焦點
                                //否則rowStatus取不到狀態值
                                rowStatus = dgvDetails.GetDataRow(curRow).RowState.ToString();
                                if (rowStatus == "Added" || rowStatus == "Modified")
                                {
                                    myCommand.Parameters.Clear();
                                    if (rowStatus == "Added")
                                    {
                                        myCommand.CommandText = sql_item_i;
                                    }
                                    else
                                    {
                                        myCommand.CommandText = sql_item_u;
                                    }
                                    myCommand.Parameters.AddWithValue("@id", txtID.Text);
                                    myCommand.Parameters.AddWithValue("@sequence_id", dgvDetails.GetRowCellValue(curRow, "sequence_id").ToString());
                                    if (dgvDetails.GetRowCellValue(curRow, "is_large").ToString() == "True")
                                    {
                                        is_large = true;
                                    }
                                    else
                                    {
                                        is_large = false;
                                    }
                                    myCommand.Parameters.AddWithValue("@is_large", is_large);
                                    myCommand.Parameters.AddWithValue("@goods_id", dgvDetails.GetRowCellValue(curRow, "goods_id").ToString());
                                    myCommand.Parameters.AddWithValue("@sec_qty", clsPub.Return_Float_Value(dgvDetails.GetRowCellValue(curRow, "sec_qty").ToString()));
                                    myCommand.Parameters.AddWithValue("@amt_total", clsPub.Return_Float_Value(dgvDetails.GetRowCellValue(curRow, "amt_total").ToString()));
                                    myCommand.Parameters.AddWithValue("@amt_other", clsPub.Return_Float_Value(dgvDetails.GetRowCellValue(curRow, "amt_other").ToString()));
                                    myCommand.Parameters.AddWithValue("@rmk", dgvDetails.GetRowCellValue(curRow, "rmk").ToString());
                                    myCommand.ExecuteNonQuery();
                                }
                            }
                        }

                        myTrans.Commit();                         //數據提交
                        save_flag = true;
                    }
                    catch (Exception E)
                    {
                        myTrans.Rollback();                         //數據回滾
                        save_flag = false;
                        throw new Exception(E.Message);
                    }
                    finally
                    {
                        myCon.Close();
                    }
                }
            }
            #endregion

            SetButtonSatus(true);
            SetObjValue.SetEditBackColor(tabPage1.Controls, false);
            Set_Grid_Status(false);
            txtID.Properties.ReadOnly = true;
            mState = "";
            dtTempDel.Clear();

            if (save_flag)
            {
                Find_doc(txtID.Text);
                MessageBox.Show("当前数据保存成功!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show("当前数据保存失败!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Stop);
            }
        }
예제 #8
0
        private void Save()
        {
            if (edit_mode == false)
            {
                MessageBox.Show("不是編輯狀態!");
                return;
            }
            if (!checkValid())
            {
                return;
            }
            string clr_grp = "";
            string strSql  = "";
            int    result  = 0;

            clr_grp = txtClr_Grp.Text;
            if (select_tab == 0)
            {
                string cdesc = txtCdesc.Text;
                if (edit_flag == "1")//新增
                {
                    strSql = string.Format(@"INSERT INTO mm_color_group (clr_grp,cdesc,crusr,crtim)
                    VALUES ('{0}','{1}','{2}',GETDATE())", clr_grp, cdesc, userid);
                }
                else
                {
                    strSql = string.Format(@"UPDATE mm_color_group SET cdesc='{0}',crusr='******',crtim=GETDATE()
                    WHERE clr_grp='{2}'"
                                           , cdesc, userid, clr_grp);
                }
            }
            else
            if (select_tab == 1)
            {
                string clr_id = txtClr_Id.Text;
                if (edit_flag == "1")    //新增
                {
                    strSql = string.Format(@"INSERT INTO mm_color_group_details (clr_grp,clr_id,crusr,crtim)
                    VALUES ('{0}','{1}','{2}',GETDATE())", clr_grp, clr_id, userid);
                }
                else
                {
                    strSql = string.Format(@"UPDATE mm_color_group_details SET crusr='******',crtim=GETDATE()
                    WHERE clr_grp='{1}' And clr_id='{2}'"
                                           , userid, clr_grp, clr_id);
                }
            }

            result = clsApp.ExecuteSqlUpdate(strSql);
            if (result > 0)
            {
                MessageBox.Show(myMsg.msgSave_ok, myMsg.msgTitle);
            }
            else
            {
                edit_flag   = "0";
                append_mode = false;
                edit_mode   = false;
                loadData();
                setTextBoxEnabled();
                addNew();
            }
        }