private void constructMenuItems(Button btn) { MAuxilaryDocSubItem adi = (MAuxilaryDocSubItem)btn.Tag; ContextMenu btnContext = new ContextMenu(); MenuItem mi1 = new MenuItem(); mi1.Name = "mnuAdd"; mi1.Tag = adi; mi1.Click += mnuAdd_Click; mi1.Header = CLanguage.getValue("add"); MenuItem mi2 = new MenuItem(); mi2.Name = "mnuDelete"; mi2.Tag = adi; mi2.Click += mnuDelete_Click; mi2.Header = CLanguage.getValue("delete"); btnContext.Items.Add(mi1); btnContext.Items.Add(new Separator()); btnContext.Items.Add(mi2); btn.ContextMenu = btnContext; }
private void LoadData() { this.Title = Caption; CTable t = new CTable(""); vw = new MAccountDocItem(t); vw.CreateDefaultValue(); DataContext = vw; vw.SelectType = "1"; CUtil.EnableForm(false, this); if (Mode.Equals("E")) { CTable newDB = actualView.GetDbObject().Clone(); vw.SetDbObject(newDB); vw.InitItemDetails(); } else { for (int i = 1; i <= 1; i++) { MAuxilaryDocSubItem mi = new MAuxilaryDocSubItem(new CTable("")); vw.AddItemDetail(mi); } } vw.NotifyAllPropertiesChanged(); vw.IsModified = false; CUtil.EnableForm(true, this); }
private void mnuAddHotKey_Click(object sender, RoutedEventArgs e) { int idx = vw.ItemDetails.Count; MAuxilaryDocSubItem mi = new MAuxilaryDocSubItem(new CTable("")); vw.InsertItemDetail(idx, mi); vw.CalculateSubItemTotal(); vw.IsModified = true; }
private void mnuAdd_Click(object sender, RoutedEventArgs e) { MenuItem mni = (MenuItem)sender; MAuxilaryDocSubItem itm = (MAuxilaryDocSubItem)mni.Tag; int idx = CUtil.StringToInt(itm.Index); MAuxilaryDocSubItem mi = new MAuxilaryDocSubItem(new CTable("")); vw.InsertItemDetail(idx, mi); vw.CalculateSubItemTotal(); vw.IsModified = true; }
private void addItemFromPayroll(ArrayList arr, int type) { String projectVariable = "PAYROLL_PROJECT_CODE"; String serviceVariable = "PAYROLL_SERVICE_CODE"; if (type == 2) { serviceVariable = "SOCIAL_SECURITY_SERVICE_CODE"; } String projectCode = CGlobalVariable.GetGlobalVariableValue(projectVariable); CTable p = getObject(projectCode, "PROJECT_CODE", "GetProjectList", "PROJECT_LIST"); MProject pj = new MProject(p); String serviceCode = CGlobalVariable.GetGlobalVariableValue(serviceVariable); CTable s = getObject(serviceCode, "SERVICE_CODE", "GetServiceList", "SERVICE_LIST"); MService sv = new MService(s); foreach (MVPayrollDocument pd in arr) { CTable t = new CTable(""); MAccountDocItem mdi = new MAccountDocItem(t); mdi.CreateDefaultValue(); mdi.SelectType = "1"; mdi.ServiceObj = sv; mdi.ProjectObj = pj; vw.AddAccountDocItem(mdi); MAuxilaryDocSubItem mi = new MAuxilaryDocSubItem(new CTable("")); mi.Description = String.Format("{0}-{1} {2}", pd.FromSalaryDateFmt, pd.ToSalaryDateFmt, pd.EmployeeTypeDesc); mi.SubItemDate = pd.ToSalaryDate; mi.UnitPrice = pd.ReceiveAmount; if (type == 2) { mi.UnitPrice = pd.SocialSecurityCompanyAmount; } mi.Quantity = "1.00"; mdi.AddItemDetail(mi); mdi.CalculateSubItemTotal(); mdi.SerializeItemDetails(); } }
private void btnImport_Click(object sender, RoutedEventArgs e) { string[] lines = System.IO.File.ReadAllLines(@"D:\tollfree.txt"); int cnt = lines.Length; for (int i = 0; i < cnt; i++) { if (i == 0) { //Comment line continue; } String line = lines[i]; MAuxilaryDocSubItem mi = new MAuxilaryDocSubItem(new CTable("")); string[] fields = line.Split('|'); String date = fields[0]; String desc = fields[1]; String invoice = fields[2]; String amtBeforeVat = fields[5]; String vat = fields[6]; String amtAfterVat = fields[7]; string[] dateComponents = date.Split('/'); int year = 2000 + CUtil.StringToInt(dateComponents[2]); int month = CUtil.StringToInt(dateComponents[0]); int day = CUtil.StringToInt(dateComponents[1]); mi.SubItemDate = new DateTime(year, month, day); mi.UnitPrice = amtAfterVat; //(CUtil.StringToDouble(vat) + CUtil.StringToDouble(amtAfterVat)).ToString(); mi.Quantity = "1"; mi.Description = "ค่าทางด่วน" + " (" + invoice + ")"; mi.ExtFlag = "A"; vw.AddItemDetail(mi); } vw.IsModified = true; }
private void mnuDelete_Click(object sender, RoutedEventArgs e) { MenuItem mni = (MenuItem)sender; MAuxilaryDocSubItem itm = (MAuxilaryDocSubItem)mni.Tag; if (vw.ItemDetails.Count <= 1) { CHelper.ShowErorMessage("", "ERROR_MUST_KEEP", null); return; } Boolean result = CHelper.AskConfirmMessage(itm.Index, "CONFIRM_DELETE_DATA"); if (!result) { return; } vw.RemoveItemDetail(itm); vw.CalculateSubItemTotal(); vw.IsModified = true; }