private void DeleteMaterialBtn_Click(object sender, RoutedEventArgs e)
        {
            if (currMaterial == null)
            {
                return;
            }
            MessageBoxResult result = MessageBox.Show($"你确定要删除 {currMaterial.name} 吗?", "提示", MessageBoxButton.YesNo, MessageBoxImage.Warning);

            if (result == MessageBoxResult.Yes)
            {
                int res = DatabaseOPtionHelper.GetInstance().delete(currMaterial);
                if (res > 0)
                {
                    String cateid = currMaterial.categoryId;
                    new System.Threading.Thread(new System.Threading.ThreadStart(() =>
                    {
                        String condition = MaterialCategoryEnum.id.ToString() + "=" + Constract.valueSplit + cateid + Constract.valueSplit;
                        CommonModel.FieldTryDesc(DataTabeName.material_category.ToString(), MaterialCategoryEnum.children_count.ToString(), 1, condition);
                    })).Start();

                    MessageBox.Show("删除成功!");
                    currMaterial = null;
                    this.MatereialDetailInfoGrid.DataContext = null;
                    materialNeedRefresh = true;
                    FillMaterialData();
                }
                else
                {
                    MessageBox.Show("删除失败!");
                }
            }
            else
            {
                return;
            }
        }
        /// <summary>
        /// Get Weighing Number 获取磅单
        /// </summary>
        /// <param name="WeightingBillType"> CK OR RK</param>
        /// <param name="ExtStr"> BL OR WL</param>
        /// <param name="noaml">true 正常过磅 false WeightingBillType + CurrentDateTime</param>
        /// <returns></returns>
        public static String GetWeighingNumber(WeightingBillType type, bool noaml = true, String ExtStr = null)
        {
            if (noaml == false)
            {
                return(type.ToString() + MyHelper.DateTimeHelper.getCurrentDateTime(MyHelper.DateTimeHelper.BillNumberDateTimeFormat));
            }
            String header = string.Empty;

            if (App.currentCompany.customerType == (int)CompanyCustomerTyle.Person)
            {
                if (String.IsNullOrEmpty(App.currentCompany.nameFirstCase))
                {
                    header = MyHelper.StringHelper.GetFirstPinyin(App.currentCompany.name);
                }
                else
                {
                    header = App.currentCompany.nameFirstCase;
                }
            }
            else
            {
                if (string.IsNullOrEmpty(App.currentCompany.abbreviationFirstCase))
                {
                    if (!String.IsNullOrEmpty(App.currentCompany.abbreviation))
                    {
                        header = MyHelper.StringHelper.GetFirstPinyin(App.currentCompany.abbreviation);
                    }
                    else
                    {
                        if (String.IsNullOrEmpty(App.currentCompany.nameFirstCase))
                        {
                            header = MyHelper.StringHelper.GetFirstPinyin(App.currentCompany.name);
                        }
                        else
                        {
                            header = App.currentCompany.nameFirstCase;
                        }
                    }
                }
                else
                {
                    header = App.currentCompany.abbreviationFirstCase;
                }
            }
            String dateStr = MyHelper.DateTimeHelper.getCurrentDateTime(MyHelper.DateTimeHelper.BillNumberDateTimeFormat);

            string sort  = string.Empty;
            int    count = CommonModel.GetTodayCount(type);

            switch (count.ToString().Length)
            {
            case 1:
                sort = "000" + (count + 1).ToString();
                break;

            case 2:
                sort = "00" + (count + 1).ToString();
                break;

            case 3:
                sort = "0" + (count + 1).ToString();
                break;

            default:
                sort = (count + 1).ToString();
                break;
            }
            if (String.IsNullOrEmpty(ExtStr))
            {
                return(type.ToString().ToUpper() + "-" + header + dateStr + sort);
            }
            else
            {
                return(type.ToString().ToUpper() + "-" + ExtStr.ToUpper() + "-" + header + dateStr + sort);
            }
        }
Esempio n. 3
0
        private void saveBtn_Click(object sender, RoutedEventArgs e)
        {
            SqlDao.DbHelper optionHelper = DatabaseOPtionHelper.GetInstance();
            int             res          = 0;

            if (!String.IsNullOrEmpty(mMaterial.id))
            {
                //update
                mMaterial.name          = this.nameTb.Text;
                mMaterial.nameFirstCase = StringHelper.GetFirstPinyin(mMaterial.name);
                mMaterial.syncTime      = (Int32)DateTimeHelper.GetTimeStamp();
                res = optionHelper.update(mMaterial);
                if (res > 0)
                {
                    MessageBox.Show("修改成功!");
                    RefreshParentData();
                    this.Close();
                }
                else
                {
                    MessageBox.Show("修改失败!");
                    return;
                }
            }
            else
            {
                //insert
                if (mMaterial.isDelete == 1)
                {
                    mMaterial.isDelete       = 0;
                    mMaterial.deleteTime     = null;
                    mMaterial.nameFirstCase  = StringHelper.GetFirstPinyin(mMaterial.name);
                    mMaterial.updateTime     = DateTimeHelper.getCurrentDateTime();
                    mMaterial.updateUserId   = App.currentUser.id;
                    mMaterial.updateUserName = App.currentUser.name;
                    mMaterial.syncTime       = DateTimeHelper.GetTimeStamp();
                    res = optionHelper.update(mMaterial);
                }
                else
                {
                    if (String.IsNullOrEmpty(mMaterial.categoryId) || String.IsNullOrEmpty(mMaterial.categoryName))
                    {
                        MessageBox.Show("添加物资名称必须先选择物资的分类!");
                        return;
                    }
                    mMaterial.id            = Guid.NewGuid().ToString();
                    mMaterial.name          = this.nameTb.Text.Trim();
                    mMaterial.addtime       = DateTimeHelper.getCurrentDateTime();
                    mMaterial.addUserId     = App.currentUser.id;
                    mMaterial.addUserName   = App.currentUser.name;
                    mMaterial.isDelete      = 0;
                    mMaterial.deleteTime    = null;
                    mMaterial.syncTime      = DateTimeHelper.GetTimeStamp();
                    mMaterial.nameFirstCase = StringHelper.GetFirstPinyin(mMaterial.name);
                    res = optionHelper.insert(mMaterial);
                }
                if (res > 0)
                {
                    MessageBox.Show("保存成功!");

                    new System.Threading.Thread(new System.Threading.ThreadStart(() => {
                        String condition = MaterialCategoryEnum.id.ToString() + "=" + Constract.valueSplit + mMaterial.categoryId + Constract.valueSplit;
                        CommonModel.FieldTryAsc(DataTabeName.material_category.ToString(), MaterialCategoryEnum.children_count.ToString(), 1, condition);
                    })).Start();

                    RefreshParentData();
                    ChangeCategoryChildredCount();
                    this.Close();
                }
                else
                {
                    MessageBox.Show("保存失败!");
                    return;
                }
            }
        }